import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;

public class DatabaseTest extends JFrame
{
  JTextField hostField;
  JTextArea queryField;
  QueryTableModel qtm;
  public DatabaseTest()
  {
    super("Database ornek penceresi");
    addWindowListener(new BasicWindowMonitor());
    setSize(350,200);
    qtm=new QueryTableModel();
    JTable table=new JTable(qtm);
    JScrollPane scrollpane=new JScrollPane(table);
    JPanel p1=new JPanel();
    p1.setLayout(new GridLayout(3,2));
    p1.add(new JLabel(" url ismini giriniz :"));
    p1.add(hostField=new JTextField("jdbc:odbc:prog"));
    p1.add(new JLabel("SQL Query deyiminizi giriniz :"));
    p1.add(queryField=new JTextArea("select *\n from KAHVE"));
    p1.add(new JLabel("Query'nizi gondermek icin buraya basiniz:"));
    JButton jb=new JButton("SQL deyimini calistir");
    jb.addActionListener(new ActionListener()
      {
      public void actionPerformed(ActionEvent e)
        {
        qtm.setHostURL(hostField.getText().trim());
        qtm.setQuery(queryField.getText().trim());
        }
      }); // jb.addActionlistener
  p1.add(jb);
  getContentPane().add(p1,BorderLayout.NORTH);
  getContentPane().add(scrollpane,BorderLayout.CENTER);
  } //DatabaseTest()

  public static void main(String args[])
  {
   DatabaseTest tt=new DatabaseTest();
   tt.setVisible(true);
  }
}
