• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Swapping Panels in an Applet

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I am moderately experienced in Java, but inexperienced in making GUI's and even less experienced in applets. So, I have an applet that has a panel. I want to be able to have an actionListener in this panel swap panels in the applet. Here is some example code to illustrate what I need:



My solution after much thinking was to pass around an instance of the applet to all the panels, but I have no idea if this is good form or a terrible idea. So something like:



Is this good form or is there a better, more standard way of doing this. I've looked around, but almost all the examples I found were too simple.


Thanks
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This has nothing to do with Applets per se ... all you need is a CardLayout.


Regards,
Rok
 
Larry Homes
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Yes I didn't know whether to post this in the swing forum or here.

So using cardlayout, something like this?



Is there a more elegant way of finding the panel with the CardLayout than a chain of getParent()?


Thanks for the help
 
Sheriff
Posts: 27525
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't say "more elegant", I would say "more usual"; just pass around references to anybody who needs them:
 
reply
    Bookmark Topic Watch Topic
  • New Topic