| Author |
Switching between the frames
|
jaspreet manchinda
Ranch Hand
Joined: Feb 27, 2012
Posts: 64
|
|
|
i just wanted to knw how to switch between the frames with a button click there are three forms with next and previous buttons so when i click on next button it should go on next form and by clicking on previous button it should go on previous form so please help me how to do it....
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
That's called a "wizard" (I don't know why). So your google keywords would be swing wizard.
|
 |
jaspreet manchinda
Ranch Hand
Joined: Feb 27, 2012
Posts: 64
|
|
i have uploaded my two frames code n third is similar one so can i connect them directly or wizard is the only option i got to make it work
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 919
|
|
You need to have 2 panels and not 2 frames (and not certainly with 2 main() methods which are 2 different programs).
Just have one frame, set the layout to CardLayout and add the panels one by one in the order you want them to appear. Then you can use the 'next()' and 'previous()' methods of the CardLayout to get the wizard behaviour.
|
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8434
|
|
@Jaspreet,
You need to post your code between the code tags
OR
select the code and click the code tag button
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
jaspreet manchinda
Ranch Hand
Joined: Feb 27, 2012
Posts: 64
|
|
|
thank you for reply bot it would be a great help if you can give me some small example with the code i mentioned earlier
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Use a CardLayout to switch between the contents of the different "frames".
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
jaspreet manchinda
Ranch Hand
Joined: Feb 27, 2012
Posts: 64
|
|
Finally came out with something but its still giving an error
java.awt.event.actionlistener is abstract cannot be instantiated
code is as follows
i'am getting error in line number 59
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
That's because you're trying to create a new ActionListener(i). However, ActionListener is an interface and cannot be instantiated like that. You do know how to create an anonymous ActionListener as that's what you do just below that. Did you perhaps create an ActionListener implementation that you meant to instantiate instead?
|
 |
jaspreet manchinda
Ranch Hand
Joined: Feb 27, 2012
Posts: 64
|
|
yes @rob i got that so i made some changes in code and now its running properly thank you every one for your time reply and help
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You're welcome.
|
 |
 |
|
|
subject: Switching between the frames
|
|
|