I'm creating an app that includes a JTable. However, I don't want the JTable to appear upon the initial launch of the application. I have a File/New menu that I want the user to use to make the JTable appear for the first time with one new row in it. This is what I have for my actionPerformed(ActionEvent event) method:
In the method createTable() the JTable is added to the JFrame's contentPane. When the app loads only the menus appears, which is what I want. Now, when the user selects File/New this actionPerformed(...) method runs. The problem is the three calls to table.validate(), table.repaint(), and container.repaint() do nothing. The JTable doesn't appear. Please advise.
if you drag the frame a little wider, does the table show up?
would be a lot easier if you'd posted a sample demo program,
just a frame, menu, non-showing table, and the listener code.
Joined: Sep 24, 2003
If I select the File/New menu, no JTable appears, however, if I resize the window, then yes the JTable suddenly appears. setVisible(true) is called initially when the app launches, I just don't include the creation of the Jtable at that time. The user must select the File/New menu to make that happen. Following is most of the code that makes up the application:
Joined: Jun 09, 2003
if it shows after making the frame wider, you're probably missing the indicated line