Java-Linux,
I've been getting deeper into UserInterface design
recently and have noticed many design issues that I am
comming up against as my interfaces/programs are getting
larger and more complex. And I was hoping maybe some of you
could point me in the right direction.
My GOAL is to be able to break my UserInterface down into
smaller classes that can all be instantiated and used by the
main interface. For example have a ButtonPanel,
NavigationPanel, DisplayPanel and seperate listener classes
for each of those different types of panels. Then have a
UserInterface class that instantiates all of them and builds
the UI. The problems I am running into, as you can imagine,
is getting objects back and forth between these classes
CLEANLY. For an example. Lets say I have these 3 following
classes, one of which is a listener:
/* Class Listener */
public class iHearYou implements ActionListener
{
actionPerformed( ActionEvent e )
{
// Do something complex, create a new graphical
component as a result
// that needs to be added to the UI.
}
}
/* Class Panel */
public class controlMe extends JPanel
{
JButton a = new JButton( "Hi!" );
iHearYou newEar = new iHearYou();
a.addActionListener( newEar );
add( a );
}
/* Class UI */
{
controlMe S&M = new controlMe();
getContentPane().add( S&M );
}
No assuming I click that button, which is being contained by
the UI class, that action propogates all the way down to the
action listener, where a new UI components (lets say a
JLabel) is created, and consequently wants to be added to
my UI WITH a specific layout directive (lets say
BorderLayout.NORTH). some might say "create an add method",
but the problem there that I percieve is lets say I have a
100 buttons that do something different and have to add
there component someplace else depending on many different
variables. Then my generic add() method has to either become
insanely complex or I have to find another way around this.
None the less, how do I cleanly get my object back to the
main UI class and have it be added to the UI?
More importantly, is THIS good design that I have outlined
above? Or should I have the extended JPanel class listening
to itself? I don't like that idea, because it doesn't
inantely seem OOP to me. So I've tried to break things up.
But now I am getting confused about which road to head down.
My goal would to be to create complex user interfaces so
obviously I need to tackle this sooner or later.
--
[ Riyad Kalla ]
[ [EMAIL PROTECTED] ]
[ CS - Major ]
[ University of Arizona ]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]