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 + Cardlayout + what is the best way to program the panels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing + Cardlayout + what is the best way to program the panels" Watch "Swing + Cardlayout + what is the best way to program the panels" New topic
Author

Swing + Cardlayout + what is the best way to program the panels

Federico Techera
Greenhorn

Joined: Jun 09, 2013
Posts: 13
Hello, I'm learging with a real life program that I need.

Now I have the Swing toolbar with icons, and each icon call to a different panel using Cardlayout.

Now I need to code what every panel need to do.

What is the normal way to do this?

1) Coding every panel inside the same aplication and the same Swing GUI...

or

2) Coding every panel like one individual piece of code, by example a standard jpanel.. and when the code is right copy and paste or import the code inside the real application?

Thanks
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Typically you would create different .java files extending JPanel
e.g.

Then you would create instances of these panels and use them in your card layout
e.g.


Recommended reading http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Federico Techera
Greenhorn

Joined: Jun 09, 2013
Posts: 13
Maneesh Godbole wrote:Typically you would create different .java files extending JPanel
e.g.


Thanks a lot Maneesh! I will try the weekend and then inform here my results
 
jQuery in Action, 2nd edition
 
subject: Swing + Cardlayout + what is the best way to program the panels