Simple gui container design.

V

VisionSet

I have a series of Components to be placed inside a Container.

Widget A goes in Panel 1 or 2
Widget B goes in Panel 2 or 3
Widget C goes in Panel 1 or 3

That is simplified slightly I have 6 components that variously appear in 3
Panels.

Only 1 Panel will exist in any one exectuion of the program.

I want a good simple design that accomplishes this.

My design head is on holiday this week ;-)
Does anyone else get that? A series of days where the code flys out with
great confidence, and another set of days where just a few lines, simple
alogrithm etc is such hard work.
 
V

VisionSet

VisionSet said:
I have a series of Components to be placed inside a Container.

Widget A goes in Panel 1 or 2
Widget B goes in Panel 2 or 3
Widget C goes in Panel 1 or 3

That is simplified slightly I have 6 components that variously appear in 3
Panels.

Only 1 Panel will exist in any one exectuion of the program.

Perhaps, I'm not being clear.

I may end up with either:

A Panel made up of Widget A & B
or
A Panel made up of Widget B & C
or
A Panel made up of Widget A & C

Anyone offer a decent way to design this?
I want a good simple design that accomplishes this.

My design head is on holiday this week ;-)
Does anyone else get that? A series of days where the code flys out with
great confidence, and another set of days where just a few lines, simple
alogrithm etc is such hard work.

TIA
 
T

Thomas G. Marshall

VisionSet said:
Perhaps, I'm not being clear.

I may end up with either:

A Panel made up of Widget A & B
or
A Panel made up of Widget B & C
or
A Panel made up of Widget A & C

I'd probably use a CardLayout, or something similar, to have 3 layers. Each
with each pair combination. This would allow you to carefully layout each
pair in a more careful way than you could if you tried to dynamically add
and remove components from the panel.
 
V

VisionSet

Thomas G. Marshall said:
I'd probably use a CardLayout, or something similar, to have 3 layers. Each
with each pair combination. This would allow you to carefully layout each
pair in a more careful way than you could if you tried to dynamically add
and remove components from the panel.

Thanks Thomas but,
I don't need to dynamically add or remove components.
Only one of those options is produced for a single execution of the
program/VM.
This question is more about good OO design and really isn't peculiar to GUI.

ie

I'd like to get an object of class 'X'
'X' could be composed of object of class 'A' & 'B'
or
'X' could be composed of object of class 'B' & 'C'
or
'X' could be composed of object of class 'A' & 'C'

I don't think that class X should have attributes A, B, C since one will
always be null.

Perhaps a Factory that dispenses A, B & C, but then what do I contain them
in?

Actually the 'X' is misleading since it clearly cannot be represented by a
single class. Just that:

X with A & B
Y with B & C
Z with A & C

does not seem a coherent design, just too disjointed. When X, Y & Z are so
related.

so may be superclass with X, Y, Z subclasses then a separate Factory. The
superclass cannot be the factory, A, B & C are not common to each
subclasses.
So really a superclass has little purpose - oh there already is one - its
called JPanel ;-)

Surely this very simple set of code which is nothing more that 6 simple
widgets (buttons & textfields) and 3 different methods of laying out some of
those 6 - can be drawn in to some coherent design without seeming so
disparate.

I'm not confusing things, considering actions & model at this point I hope
that will just slot into place when I've figured this out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top