Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
package src.gui;
import javax.swing.*;
import java.util.Vector;
import java.awt.*;
import javax.swing.border.TitledBorder;
import java.sql.*;
import java.awt.event.*;
/**
* This class is used
*/
public class ClientFrame extends JFrame{
private DefaultListModel tablesDefaultListModel = null;
private JButton connectButton = new JButton("Connect to Database");
private JButton convertButton = new JButton("Convert tables to XML");
private Vector v = new Vector();
private JList tablesJList = new JList(v);
public ClientFrame() {
final int WIDTH = 600;
final int HEIGHT = 300;
setSize(WIDTH, HEIGHT);
JPanel tablesPanel = new JPanel();
JPanel buttonPanel = new JPanel();
TitledBorder titledBorder = new TitledBorder("Available Tables");
tablesJList.setBorder(titledBorder);
tablesJList.setFixedCellWidth(550);
Container contentPane = getContentPane();
setBackground(Color.white);
setForeground(Color.black);
tablesPanel.add(tablesJList);
tablesJList.setVisible(true);
tablesDefaultListModel = new DefaultListModel();
tablesJList.setModel(tablesDefaultListModel);
contentPane.add(tablesPanel, "North");
ActionListener listener = new ButtonListener();
connectButton.addActionListener(listener);
convertButton.addActionListener(listener);
buttonPanel.add(connectButton);
buttonPanel.add(convertButton);
contentPane.add(buttonPanel, "South");
}
public static void main(String[] args) {
ClientFrame frame = new ClientFrame();
frame.setTitle("Interface");
frame.show();
}
protected void processWindowEvent (WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
closeWindow();
}
}
private void closeWindow() {
dispose();
}
public class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
if(src == connectButton) {
Connection conObject = Connect.getConnection();
ResultSet result = Connect.retrieveTables(conObject);
String table = null;
try {
while(result.next()) {
table = result.getString(1);
if (!tablesDefaultListModel.contains(table)) {
tablesDefaultListModel.addElement(table);
}
}
tablesJList.setModel(tablesDefaultListModel);
}
catch(SQLException exception) {
System.out.println("An exception was raised when traversing the " +
"result set");
System.err.println(exception);
}
}
}
}
}
import javax.swing.*;
import java.util.Vector;
import java.awt.*;
import javax.swing.border.TitledBorder;
import java.sql.*;
import java.awt.event.*;
/**
* This class is used
*/
public class ClientFrame extends JFrame{
//private DefaultListModel tablesDefaultListModel = null;
private JButton connectButton = new JButton("Connect to Database");
private JButton convertButton = new JButton("Convert tables to XML");
private Vector v = new Vector();
private JComboBox tablesJList = new JComboBox(v);
public ClientFrame() {
final int WIDTH = 600;
final int HEIGHT = 300;
setSize(WIDTH, HEIGHT);
JPanel tablesPanel = new JPanel();
JPanel buttonPanel = new JPanel();
tablesPanel.setBackground(Color.red);
TitledBorder titledBorder = new TitledBorder("Available Tables");
tablesJList.setBorder(titledBorder);
tablesJList.setPreferredSize(new Dimension(550,50));
//tablesJList.setFixedCellWidth(550);
Container contentPane = getContentPane();
setBackground(Color.white);
setForeground(Color.black);
tablesPanel.add(tablesJList);
//tablesDefaultListModel = new DefaultListModel();
//tablesJList.setModel(tablesDefaultListModel);
contentPane.add(tablesPanel, "North");
ActionListener listener = new ButtonListener(tablesJList);
connectButton.addActionListener(listener);
convertButton.addActionListener(listener);
buttonPanel.add(connectButton);
buttonPanel.add(convertButton);
contentPane.add(buttonPanel, "South");
}
public static void main(String[] args) {
ClientFrame frame = new ClientFrame();
frame.setTitle("Interface");
frame.setVisible(true);
}
protected void processWindowEvent (WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
closeWindow();
}
}
private void closeWindow() {
dispose();
}
}
class ButtonListener implements ActionListener{
JComboBox pointToJCombo;
public ButtonListener(JComboBox tempCombo)
{
pointToJCombo = tempCombo;
}
public void actionPerformed(ActionEvent e) {
pointToJCombo.addItem("hello");
/*
Object src = e.getSource();
if(src == connectButton) {
Connection conObject = Connect.getConnection();
ResultSet result = Connect.retrieveTables(conObject);
String table = null;
try {
while(result.next()) {
table = result.getString(1);
if (!tablesDefaultListModel.contains(table)) {
tablesDefaultListModel.addElement(table);
}
}
tablesJList.setModel(tablesDefaultListModel);
}
catch(SQLException exception) {
System.out.println("An exception was raised when traversing the " +
"result set");
System.err.println(exception);
}
}
*/
}
}