Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wizards and CardLayout

 
Mark Fletcher
Ranch Hand
Posts: 897
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im playing about with awt and Swing and Id like to create a wizard like dialog. I figured the easiest way at first glance was to use a cardlayout for the main part of the dialog.
The problem Im having is that using the previous() and next() methods of CardLayout, I cant prevent my Next and Previous buttons from looping round to the first card again. Is there anyway I can test for the next card?
Any help greatly appreciated!
Cheers,
Mark
My code listing is below
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
Yes I think you can do that. The following code should work.

It probably would be a nicer approach to have the buttons become disabled when they shouldn't be clicked. The method below can be used for that.

The new routine would need to be called immediately before the show method and after changing the displayed card. For example, using the lower part of your code:

Regards,
Manfred.
 
Mark Fletcher
Ranch Hand
Posts: 897
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manfred,
Thanks for your reply!
Cheers
Mark
 
Brian Coates
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I implemented a wizard using this same method for enabeling/disabeling the Next & Back buttons. It works fine on my Win machine (using JDK 1.2.2_006 and 1.3.0-C), however it doesn't on a Unix box running JDK 1.3.0. The "cancel" button is enabled, but none of the others are.
My code looks like the above snipped.
Any ideas..?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic