Solved

Multiple JPanel in JApplet

Posted on 2007-11-21
2
1,141 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

914 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now