0% found this document useful (0 votes)
25 views

Javax: Import Import Import Import Public Class Extends

This Java code defines a class called DatabaseTest that creates a GUI for querying a database. It contains text fields for the host URL and query, and a button to send the query. When clicked, the button gets the text from the fields and passes it to the QueryTableModel, which will use it to query the database and display results in a scrollable table.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Javax: Import Import Import Import Public Class Extends

This Java code defines a class called DatabaseTest that creates a GUI for querying a database. It contains text fields for the host URL and query, and a button to send the query. When clicked, the button gets the text from the fields and passes it to the QueryTableModel, which will use it to query the database and display results in a scrollable table.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import import import import

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

public class DatabaseTest extends JFrame { JTextField hostField; JTextField queryField; QueryTableModel qtm; public DatabaseTest() { super("Database Test Frame"); setDefaultCloseOperation(EXIT_ON_CLOSE); 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("Enter the Host URL: ")); p1.add(hostField = new JTextField()); p1.add(new JLabel("Enter your query: ")); p1.add(queryField = new JTextField()); p1.add(new JLabel("Click here to send: ")); JButton jb = new JButton("Search"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { qtm.setHostURL(hostField.getText().trim()); qtm.setQuery(queryField.getText().trim()); } } ); p1.add(jb); getContentPane().add(p1, BorderLayout.NORTH); getContentPane().add(scrollpane, BorderLayout.CENTER); } public static void main(String args[]) { DatabaseTest tt = new DatabaseTest(); tt.setVisible(true); } }

You might also like