Solved

Multiple JPanel in JApplet

Posted on 2007-11-21
2
1,156 Views
Last Modified: 2013-11-23
This should be a simple task, but I don't do that much with Java.

5 different JPanel classes which handle their own actions have been created.  For this conversation we will call them MyPanel1 ... MyPanel 5.  The first of these is a button/keypad menu.  All of this must run within a JApplet.  When the user selects one of the buttons a new class instance is created of the appropriate class and becomes the content for the JApplet.  When the user wishes to exit that JPanel they chose an exit option and it finalizes.  The JApplet should redisplay the original menu JPanel class (MyPanel1 for this discussion).

Need to see a code snippet for the switching back and forth.

0
Comment
Question by:yyyc186
2 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20331805
a CardLayout can be used for easily switching between panels
0
 
LVL 7

Accepted Solution

by:
UrosVidojevic earned 250 total points
ID: 20331824
In my opinion, in this case it is the most appropriate to use CardLayout class, to realize that kind of panel switching.

You should have one main panel with 5 panels added to it using CardLayout. Initialy MyPanel1 instance will be visible. When user choose some button from MyPanel1, main panel will switch its content to appropriate panel. When user wants to return to MyPanel1, clicking the appropriate "exit" button will make MyPanel1 visible again.

Examples:
1.) http://www.science.uva.nl/ict/ossdocs/java/tutorial/ui/layout/card.html
2.) http://www.javareference.com/jrexamples/viewexample.jsp?id=28
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I build my own IDE using ASP.NET MVC? 2 62
jsp insert to database example 2 59
sql import cannot be resolved jsp 3 72
wild fly 8 startup error 2 37
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This video teaches viewers about errors in exception handling.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question