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!
Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
You may want to look into a CardLayout layout manager. You can put each JTable into a different "Card" and have your buttons pull up the appropriate card. Think of CardLayout as a JTabbedPane without the tabs. In fact, maybe putting them into a JTabbedPane would be a good idea. Then you could just use the tabs to switch between the two tables. Hope it helps.
For a good Prime, call:<br />29819592777931214269172453467810429868925511217482600306406141434158089
Joined: May 31, 2001
OK, here is the code that I am trying to get to work correctly. Please advise. Thanks! /******* TableTest.java *******/ /***** JTableModel *****/