Refresh panel when replacing a card

How do you update JPanel when changing a panel from a CardLayout container?

+3
source share
4 answers

Is there an actionlistener or something that I have reload / refresh my data on this screen?

You can use AncestorListener. It starts when a component is added to the Container. Therefore, when you change cards, the event leaves. You will need to add a listener to each panel that you add to CardLayout:

Another problem with CardLayout is that the panel does not focus when it is replaced. I use this approach to focus on the panel. Check out the "Focus Card" .

panel.addAncestorListener(...);
0

show(). Java API:

, , addLayoutComponent. , .

CardLayout#first(), next() previous() - .

, ( , CardLayout, , ), . , revalidate(), Swing , .

, ; , CardLayout, . , , .

+2

actionlistener -, / ?

, , (), :

  • , Observable Observer.

  • EventListenerList, ActionEvent.

, , /. CardLayout JComboBox itemStateChanged(). .

+1

show() , "" . actionlistener -, / ?

0

Source: https://habr.com/ru/post/1757373/


All Articles