Hello all,
I have a JFrame that has 2 JButtons(b1 and b2) and 2 JTables. When the JFrame first comes up, JTable1 is displayed. When b2 is clicked I want Jtable2 to be displayed. Also, if b1 is clicked later, I want JTable1 to be displayed.
You should be able to switch between the two tables in this manner.
The JTables are globals so they can be accessed anywhere in the class. I have 2 action listeners, one on each button. It is here where I am having the problem. I cannot seem to get the Jtables to switch. I am currently using a CardLayout on a JPanel with the 2 JTables added to the JPanel(also a global). In the listeners, I tell the CardLayout to switch to the next JTable using the next(JPanel) method.
This is just my latest attempt. I have also tried using the same Jtable and just switching the data contents with a new JTableModel using the setModel() method. I have also tried using the repaint() method of the JScrollPanel the JTable is in, and the JTable itself. I have also tried the fireTableDataChanged() method.
Nothing seems to be working. Any ideas?
Thanks!