File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Switching between the frames

 
jaspreet manchinda
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's called a "wizard" (I don't know why). So your google keywords would be swing wizard.
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jaspreet,
You need to post your code between the code tags
OR
select the code and click the code tag button
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a CardLayout to switch between the contents of the different "frames".
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic