Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

listen for changes in other jPanels  RSS feed

 
Tai Yo
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!
I would like to ask a question related to passing values between jPanels.
For example, I have a jFrame and 5 jPanels, I am switching jPanels by CardLayout. jPanels have a lot of jTextFields and jComboBoxes.
Every jPanel have saveButton, by clicking saveButton I am getting values from jTextFields and jComboBoxes and writing them into text file.
The layout of text file:

And I get stuck on this part:
if jTextfield3 of jPanel 3 is not empty and have some value, then it must be printed in under jPanel2 values too:

And if jTextfield3 of jPanel 3 is empty, then it must not printed in jPanel2:

I would like to ask how to listen for changes in other jPanels, how to create communication between jPanels which managed by CardLayout?

Any help is greatly appreciated.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend an event bus. Allows you to have totally loose and dynamic coupling.
Check out https://github.com/olostan/simpleventbus
and http://dev-crossroads.blogspot.in/2011/04/very-simple-eventbuspubsub.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!