GUI Data set & get

Hi All,

I have a gui made up of many individual JPanels and sub JPanels each JPanel contains some Components of varying types.

The GUI has close to 150 components, I need to be able to pass this GUI as an object to other Objects. These other objects will need access to each of the 150 Components.

I'd prefer not to have 150 set and get methods (not to mention the recursive methods necessary to access the data in the sub JPanels) I was thinking of something along the lines of a HashMap instead.

Is there a patteren or a fairly standard technique for doing this?

Or if any of you know of an efficient way to gain access to all components I'd love to hear it.

Thanks Very Much!

[724 byte] By [JNameNotTakena] at [2007-10-3 6:40:59]
# 1
I don't know if I should admit this, but it happens that I use the putClientProperty method of JComponent to "tag" the components with a logical name. I do then write a recursive loop which populates the models using the logical names.Kaj
kajbja at 2007-7-15 1:29:59 > top of Java-index,Java Essentials,Java Programming...
# 2

Thanks Kajbj

Thats interesting actually, still allot of manual labour involved though.

I was actually thinking of adding each component to a static HashMap just after I instantiate the component.

For setting and getting data I will have a class with static methods as follows.

void setData(Object component, Object data)

Object getData(Object component)

These methods can figure out what the compoent type is and set and get the Component contents (data) appropiatly.

As for actually getting the components themselves, they can be taken from the HashMap.

JNameNotTakena at 2007-7-15 1:29:59 > top of Java-index,Java Essentials,Java Programming...
# 3
> but it happens that I use the putClientProperty method of > JComponent to "tag" the components with a logical name.The component class has a setName(...) method.
camickra at 2007-7-15 1:29:59 > top of Java-index,Java Essentials,Java Programming...