Reference to primitive types?

I want to write a GUI that is able to set parameters to classes without knowing the exact nature of parameters. The parameter types are restricted to int and String. Something like this:

...in GUIclass:

ClassToConfigure c = getFromSomewhere();

for (int i=0; i<c.getPropertyCount(); i++){

addToGUI(c.getDescription(), c.getType(), c.getKeyName())

}

...

then later after the value is set in the GUI:

c.setProperty(keyName, newValue);

the setProperty method would have implementations for each type of newValue, and the GUI would have editing capabilities for each type too.

My problem is that I do not know how to implement this in the ClassToConfigure (CTC). My thoughts were: CTC enumerates all field it wants to be configurable in its constructor, something like:

...

addProperty(actual_field,"int","Some description","UniqueName");

the CTC class would have a list of all properties with the "references" to the actual field to be able to update them.

but then I don't know how to update the fields when CTC.setProperty() is called. Is there a way to keep a reference to a field, even if the field has a primitive type? Another way to do it would be using function pointers, passing the getter and setter to CTC.addProperty, but this isn't possible in java.

Is there any straightforward way of implementing such behavior in java without tricky use of reflection?

Thanks in advance,

-Lev

P.S. I hope I made my point understandable, if not please let me know and I'll try to rephrase my concern.>

[1851 byte] By [Egladila] at [2007-10-2 5:56:49]
# 1
I did not understand what you meant. But you can have the OO equivalents to function pointers, and that is method references. (But that is part of the the java.lang.reflect package)Kaj
kajbja at 2007-7-16 2:05:53 > top of Java-index,Java Essentials,Java Programming...