It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes making JTable appear after initial load Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "making JTable appear after initial load" Watch "making JTable appear after initial load" New topic
Author

making JTable appear after initial load

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi Guys,

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.

Alan

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
how is it 'not' initially showing?

setVisible(false), or not added to anything?

do you change this/these?

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.
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
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:

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if it shows after making the frame wider, you're probably missing the indicated line

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Aaahh! That was it. Thanks.

Alan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: making JTable appear after initial load
 
Similar Threads
JTable
jtable
Refreshing JTable
JTable
Jtable