• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Layouts!!!

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a bit complicated problem here..
I am writing an applet in whic there r 3 buttons on the top of the applet.On the click of the first button(calci) i should get a calculator to be displayed on the same applet .On the click of second button I should get another display having many buttons,check box,.etc doing various functions and the calculator should not be visible.I have written the code of th calci and others seperatly and r working fine.Now i am not able to put all the things in one applet.I am getting stuck as to where to write the listener code and whether to use Component or container class and how to actually use the card layout.
Can any one guide be in brief.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anand,
I would use a borderLayout to place the buttons on top or on the bottom and use a cardLayout in the center. To add to a cardlayout is pretty easy:
Panel p1 = new Panel();
Panel p2 = new Panel();
Panel p3 = new Panel();
CardLayout mainPanel = new CardLayout();
mainPanel.add( p1, "Panel1" );
mainPanel.add( p2, "Panel2" );
mainPanel.add( p3, "Panel3" );
When you want to show one of them, you just use its name:
CardLayout layout = mainPanel.getLayout();
layout.show( mainPanel, "Panel2" );
That's it!
Manfred.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic