I'm building a rich client application based on Swing. And I'm wondering what is the best architecture for event's handling.
My classes are :
- FirstPanel, with a jbutton
- SecondPanel with a jLabel
I start the application with a FirstPanel within a MyFrame.
Then, I add an action listener to the button in the FirstPanel, and I whant this action to (1) close the FirstPane then (2) open a new SecondPanel in the running MyFrame
How to do it ?
**Edit - Example**
I want to show at startup a list of users, stored in a file, then the user click on his name or click on "new user". When he clicks on "new user", a second panel appears, with a form to create a new user and store it in the file.
In this example, MyFrame is the main frame, created by the main() method.
Then the ListUsersPanel appears.
Then, the NewUserPanel appears if I click on "new user".
My question is : how do I design my classes/listeners to manage all this ?
** Edit - example 2 **
What if I have a JFrame that contains 2 JPanels, and I want a button in Panel1 that change a label in Panel2 ? you are already describing the event architecture...