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

Regarding CardLayout

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I know that in card layout we can add different cards and switch between them.
Now i have add buttons as first, last, next and previous. And i am able to do so by using this buttons.Now what i need is to get a card directly on clicking a button say xyz. Imagine you have 15 cards and you need to get the 7th card on clicking the xyz button how to do it. Please some body help me.
The code i used for first and last button is as follows for card layout with 4 cards.


This is for first button

firstb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0)
{
cl.first(panel);
currcard=1;
}
});

This is for last button

firstb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0)
{
cl.last(panel);
currcard=4;
}
});

 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that you're looking at using the show( ) method of the CardLayout, which you can find in the API here.

It takes two parameters, the first being the name of the component that is implementing the CardLayout which for you appears to be the "panel" object, and the second parameter is a String which matches the String used when you inserted your desired card component onto panel. The trick here is to retrieve this String, and that will depend on your program. One way is to create a simple array or arraylist to hold these Strings and simply retrieve the seventh item in the ArrayList (or array).
[ June 07, 2008: Message edited by: pete stein ]
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for your help its working now. But i have one more problem.
I want to add a image to a panel which can cover upto 75% of its length. I already have some text fields above. I want to add image on same panel but below the text fields. So please any body can help.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by adeeb alexander:
..But i have one more problem.



Would you please start a new thread for every new topic? Usually people scroll through the thread list, reading the subject line for topics of interest. Having multiple topics in the same thread makes it difficult for them.
[ June 09, 2008: Message edited by: Maneesh Godbole ]
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic