This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "About multiple extending classes" Watch "About multiple extending classes" New topic

About multiple extending classes

Shay Gaghe
Ranch Hand

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

[This message has been edited by Shay Gaghe (edited October 24, 2001).]
Nathan Pruett

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..


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
wood burning stoves
subject: About multiple extending classes
Similar Threads
extending an extended class
dispating events in ver 1.3
Collaboration between separate parts(classes) in the same framework
Problem on extending an extended class
starting RMI...