Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

swing beginner - getting a jpanel launched by clicking a button

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi. just getting my feet wet with a desktop swing database app. i'm using postgres along with netbeans 6.5.1.

followed the sun/netbeans doc and got a single jpanel app working that binds to one table. it operates as billed, allowing me to scroll through the records in one table, edit them, and add new ones. this start i created with the wizard in netbeans.

however i get stuck when i try to add another such jpanel to perform the same operations on a second table. for this one, i used created another jpanel class. the way i attempt to invoke it is to create a new jbutton on the first, working form. then i add an action listener that is as follows, attempting to create a new form and set its visible property to true:



the print statement indeed works when i press the jbutton, so i know ithe listener is getting called. but the deptForm jpanel never appears. i ran it in debug too and it seems to execute each step in the listener, but the new jpanel never comes up.

can you please help?

thank you.
gt
 
Sheriff
Posts: 22567
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add it to a container. And while you're doing that, you should read http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html
 
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In addition to what Rob says, It seems to me a CardLayout for the container might be appropriate, though maybe not an absolute necessity.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic