File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About multiple extending classes

 
Shay Gaghe
Ranch Hand
Posts: 102
  • 0
  • 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:



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).]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you making seperate classes to hold each GUI element? Normally, you would just add regular JButton/JList to MainClass... this also makes it harder to do event handling normally, because you somehow have to be able to access the GUI elements inside your class to treat them like GUI elements...

Aside from that, the problem is that you are specializing your GUI components too much inside the seperate classes... at the ButtonClass level, ButtonClass shouldn't know that it needs to interface with ListClass... you should handle all of that later in the MainClass... something like this... it is still a little too specialized, though. You really need to just use regular GUI components instead of extending them this way..







-Nate
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic