File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes swing beginner - getting a jpanel launched by clicking a button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "swing beginner - getting a jpanel launched by clicking a button" Watch "swing beginner - getting a jpanel launched by clicking a button" New topic
Author

swing beginner - getting a jpanel launched by clicking a button

glok twen
Greenhorn

Joined: Jul 02, 2007
Posts: 9
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

Joined: Oct 27, 2005
Posts: 19718
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
In addition to what Rob says, It seems to me a CardLayout for the container might be appropriate, though maybe not an absolute necessity.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: swing beginner - getting a jpanel launched by clicking a button