How do you update JPanel when changing a panel from a CardLayout container?
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(...);
show(). Java API:
show()
, , addLayoutComponent. , .
CardLayout#first(), next() previous() - .
CardLayout#first()
next()
previous()
, ( , CardLayout, , ), . , revalidate(), Swing , .
CardLayout
revalidate()
, ; , CardLayout, . , , .
actionlistener -, / ?
, , (), :
, Observable Observer.
Observable
Observer
EventListenerList, ActionEvent.
EventListenerList
ActionEvent
, , /. CardLayout JComboBox itemStateChanged(). .
JComboBox
itemStateChanged()
show() , "" . actionlistener -, / ?
Source: https://habr.com/ru/post/1757373/More articles:Windows application in C - c ++Compact LINQ syntax for floating point ranges? - c #Является ли это правильным способом интеграции Zend Framework с Doctrine 2? - zend-frameworkIs it good to have MVVM without a model for temporary things? - c #How can I use NYTProf in the library - profilingIn a Cocoa CLI application, how to implement an event loop? - objective-cjquery javascript find how far the element with position remains: relative - jqueryCreating the main event loop (for hotkeys, etc.) - objective-cVisual Studio go to implementation - methodspackage to check if one file is modified - batch-fileAll Articles