wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Switching between the frames 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 "Switching between the frames " Watch "Switching between the frames " New topic
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: 18541
    
    8

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: 1076
    
  10

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: 10268
    
    8

@Jaspreet,
You need to post your code between the code tags
OR
select the code and click the code tag button


[How to ask questions] [Donate a pint, save a life!] [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: 19674
    
  18

Use a CardLayout to switch between the contents of the different "frames".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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: 19674
    
  18

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: 19674
    
  18

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Switching between the frames