Vitali,
You are absolutely correct, it can be a design restriction to give
all those fields that Swixml should automatically map public access.
Remember how the SwingEngine does this:
While parsing your XML layout descriptor, the SwingEngine
instantiates all the JCompontents and Wigets and assembles the GUI tree.
In case you provided tag in the XML descriptor with an id attribute,
the SwingEngine will also put a reference to the instantiated Object
into a so-called idmap. After all this is done, the SwingEngine tries
to introspect the class of the client object you provided when
setting-up the SwingEngine.
If during this introspection public Members are found whose names
match those in the idmap, the SwingEngine maps the reference into the
Member variable. This however, can only be done for public members.
If this becomes a concern - and it sometimes really can - then you
can just do the mapping yourself, inside the client class, where you
don't have to consider just public members anymore.
The SwingEngine gives you access to the idmap.:
Map getIdMap()
Returns the id map, containing all id-ed parsed GUI
components.
For convenience, there is also the getIdComponentIterator:
Iterator getIdComponentItertor()
Returns an Iterator for id-ed parsed GUI components.
and in case you just need to map a few known ids, you can simply use
the find method:
Component find(String id)
Returns the UI component with the given name or null.
--
Wolf Paulus
707.202.3937
[EMAIL PROTECTED]
C a r l s b a d C u b e s
Dedicated to Excellence
CONFIDENTIALITY NOTICE:
This message is intended only for the use of the individual or entity
to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable
law. If you are not the intended recipient, please contact the sender
by reply email and destroy all copies of the original message.
On May 27, 2005, at 1:58 AM, Forum@carlsbadcubes.com wrote:
Hi,
I think this is quite a serious design restriction that swixml
requires
client's fields to be public. This make them unnecessarily accessible
from other parts of application so they can be unintentionally
modified.
Though this is very easy to fix. SwingEngine.mapMembers method has
to be modified something like this
-Field[] flds = obj.getClass().getFields();
+Field[] flds = obj.getClass().getDeclaredFields();
+AccessibleObject.setAccessible(flds, true);
Thanks,
Vitali.
Sorry if this message appears twice. The original message was not
posted somehow.
Hey Frank,
I have solved the problem. It occured because I declared my Swing
Components 'private' and therefore the automatic initialization by
the SwixEngine did not work. I accidentally realized this, when
looking through some of the examples.
I think this should be put in the documentation somewhere.
Thanks so far. :)
Sebastian
<Forum@carlsbadcubes.com> schrieb im Newsbeitrag news:
[EMAIL PROTECTED]
Forum@carlsbadcubes.com wrote:
I cannot understand this, because the documention says, that the
gui components are initialized automatically.
Sebastian,
please post your xml code to allow any diagnosis...
Frank
_______________________________________________
Forum mailing list
Forum@carlsbadcubes.com
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
---
Автоцентр MAZDA и Музей современного
изобразительного искусства
приглашают посетить уникальную
экспозицию "MAZDA-шедевр" http://www.mazda.by/know/
news/~id=13~page=1
_______________________________________________
Forum mailing list
Forum@carlsbadcubes.com
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com