• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

swing beginner - getting a jpanel launched by clicking a button

 
glok twen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
 
Fred Hamilton
Ranch Hand
Posts: 684
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic