Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

making JTable appear after initial load

 
Alan Shiers
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it shows after making the frame wider, you're probably missing the indicated line

 
Alan Shiers
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaahh! That was it. Thanks.

Alan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic