• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

making JTable appear after initial load

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aaahh! That was it. Thanks.

Alan
reply
    Bookmark Topic Watch Topic
  • New Topic