so I have this code:
public class Welcome extends JFrame {
private JPanel contentPane;
private JTable table;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Welcome frame = new Welcome();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Welcome() {
setAlwaysOnTop(true);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 1024, 768);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
ScrollPane scrollPane = new ScrollPane();
scrollPane.setScrollPosition(new Point(0, 0));
scrollPane.setBounds(10, 10, 998, 719);
contentPane.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"First Name", "Last Name", "Cellphone"
}
));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setFillsViewportHeight(true);
table.setBounds(10, 10, 998, 718);
contentPane.add(table);
}
}
What I am trying to do is fill the jtable with data from the database, but I don't know how. I am thinking of having a method outside of the initialize method, and create a multidimensional array in there for the jTable to reference. I am targeting this line of code:
new Object[][] {
}
How could I make a multidimensional Object array and populate it with data from the database?? The gui was done using eclipse window builder.
Thanks, Josh