aspose 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
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: 10329
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing + Cardlayout + what is the best way to program the panels