Hi, I have recently been assigned to devlelop an inhouse swing application. Would appreciate if you could help me with your suggestions for the following problem situation.
The application shall consist of many tabbed panes. >One such tabbed pane has three/four tabs. >>Each tab of this is a JPanel. >>This JPanel has two JPanels and one JListPane >>> Each of these JPanels and JListPane have their own classes where they have smaller components laid out on them.
Requirement: On click of elements in JListPane, the JPanels should reflect some data.
Question: In what way should I define my event handlers. Is there any pattern I can use. Should I have public get/set methods for each of textboxes which everyone can access?
The problem arises because the Panels are in different classes and cannot access each other components ( like textfields etc. ) to put values on them when different events happen.
as a start, i would suggest looking at some articles on model-view-controller approaches. a strain of this approach was used in the design of JTable, and you can see the same pattern in other component designs like JList JTree etc.
to answer your question, you almost certainly don't want to expose public getters and setters for your data fields ... this is where a controller can save you some major nightmares.
lastly, you'll want to read some previous posts about the Swing Event Queue. if you're not familiar with the issues there, i'm afraid you soon will be :-T