Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collaboration between separate parts(classes) in the same framework

 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a Swing interface that I divided into separate classes (20 classes). Each class (that extends Jpanel) of them contains part of the GUI , to collect them i use a main class that instantiate each one of the classes and by running the main class I see all the GUI.
whenever i want one class to effect instance in the another class i use this code(for example i want to add element from one panel(public class) to the another Panel(public class) this how i do it now(each one is a separate public class):



As you can see, unfortunately I use static reference in the ButtonClass to change the state of the list , wish I could use other way to do the same thing without the static keyword (which I really hate , because its unwelcome by OOP design) , what is the appropriate way to do it?
Can I / should I collect those 20 classes to an Applet or Application?
Im developing a chat program that based on sockets . since the client program contains very heavyweight graphics , I wonder if using applet or application makes any different?
Thanks in advance
Sincerely
Shay Gaghe

[This message has been edited by Shay Gaghe (edited October 24, 2001).]
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think I have already answered to your question some times ago..
Anyway, one solution might be propose a constructor in ListClass which would take a ButtonClass as parameter.
In the ButtonClass, you must add new listener methods to your interface:
public void add/removeActionListener(ActionListener a) {};
When the Button is pushed, then this information is also transfered to the actionListeners of the ButtonClass.
Then in the constructor of ListClass mentioned above, you install the ListClass as an ActionListener of ButtonClass. Yet, the actionPerformed method in ListClass (or an inner class) should be:
public void actionPerformed(ActionEvent e) {
defaultListModel.addElement("Dave");
}
W.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic