
Signature
Nemo (nemo@stian.demon.co.uk)
> Is it possible to define the property tag list as the fixed resource
> keys (e.g. key_en, key_fr, key_it) and somehow translate to/from the
> locale-specific text in the GUI?
The simplest would be to use getSelectedIndex() and just work with the
index.
The second simplest would be to use the index to build a key:
String key = "SomeFixedPart_" + aComboBox.getSelectedIndex();
If your really need symbolic names, use the fact that the JComboBox
takes any kind of Object for items:
public class ComboBoxItem {
String label;
String key;
public void ComboBoxItem(String l, String k) {
label = l;
key = k;
}
public String toString() {
return label;
}
public String getKey() {
return key;
}
}
((ComboBoxItem)aComboBox.getSelectedItem()).getKey();
But this is almost overdone.
> Seems to me this must be a common i18n problem, but I've been unable to
> find anything in my searches.
There is no such problem. You are making things more complicated then
they are.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
Nemo - 11 Jun 2005 15:07 GMT
>> Is it possible to define the property tag list as the fixed resource
>>keys (e.g. key_en, key_fr, key_it) and somehow translate to/from the
>>locale-specific text in the GUI?
>
>The simplest would be to use getSelectedIndex() and just work with the
>index.
[...]
>But this is almost overdone.
>
[quoted text clipped - 3 lines]
>There is no such problem. You are making things more complicated then
>they are.
Thanks, agreed, as stated the problem was not difficult - the index
would do fine.
My fault, I failed to provide the full context.
The environment is a Bean Customiser that provides the Combo box.
The values are set from the list of Tags.
I've tried updating setAsText() and getAsText() in the PropertyEditor
but keep getting errors from the customiser saying that the selected
value was incorrect.
However on further investigation it looks as though the Customiser
and/or PropertyEditor may need updating.
On a related note, I failed to find any examples of Bean Property
Editors that support the behaviour. Nor indeed any that support Enums.
Obviously one can do both of these with radio buttons, but they are not
suitable where there are lots of possible different values.

Signature
Nemo (nemo@stian.demon.co.uk)