This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes About multiple extending classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "About multiple extending classes" Watch "About multiple extending classes" New topic
Author

About multiple extending classes

Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
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

Joined: Oct 18, 2000
Posts: 4121

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


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
GeeCON Prague 2014
 
subject: About multiple extending classes