CardLayout Doubt
Hi
I have a JPanel that uses a cardLayout with several "cards" that are added dinamically in my application. The labels that I use in the cards, however, may change during the application. So, How do I get a "card" from the layout to update (without showing the card)?
I've tryed to add the card to an ArrayList, but when I change the card in the List, the card in the layout does not change.....
[417 byte] By [
Leo77a] at [2007-11-27 4:47:53]

# 2
Its hard for me to create a small code to post... It will take some time but I'll try.but, in the meantime, How can I get a panel from a cardLayout without showing it? If you answer this question I belive I can solve my problem.
Leo77a at 2007-7-12 10:00:39 >

# 3
> but, in the meantime, How can I get a panel from a
> cardLayout without showing it? If you answer this
> question I belive I can solve my problem.
Do you really need to get the panel? What you need is a public property that allows you to change the label. Are your panels separate classes? Can you add a property to the class that holds the label?:
public void setMyLabel(String s)
{
myLabel.setText(s);
}
Or perhaps you could use the observer pattern if you want to loosen your connections as much as possible. Anything is possible with enough indirection.
# 4
I do have a public method "setMyLabel". But how can I set the label on the right Panel without getting the panel? I have several panels with different text labels to set...
And, As I've said, I've tried to add the panels to a List, so I can get then later, but when I update the panels on the list, the modifications do not appear...
Leo77a at 2007-7-12 10:00:39 >

# 5
> And, As I've said, I've tried to add the panels to a> List, so I can get then later, That should work...> but when I update the> panels on the list, the modifications do not appear...without code it is hard to say why.