arru_in
asked on
JComboBox internal value ?
I've a JComboBox, which gets populated from the database with (say)
employee names. When the user selects a employee, i need to get the employee code of that person.
Since, employee name is not unique, i can't get the employee
code from the employee name selected.
Now, consider the following html code
<select>
<option value="E00001">ARRU</optio n>
<option value="EmpCode">Employee Name</option>
</select>
There can be some internal representation for each value. Is the
same kind of thing possible in JComboBox ?
Thanks in Advance
Arru_in
employee names. When the user selects a employee, i need to get the employee code of that person.
Since, employee name is not unique, i can't get the employee
code from the employee name selected.
Now, consider the following html code
<select>
<option value="E00001">ARRU</optio
<option value="EmpCode">Employee Name</option>
</select>
There can be some internal representation for each value. Is the
same kind of thing possible in JComboBox ?
Thanks in Advance
Arru_in
String[] myStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
//Create the combo box, select item at index 4.
//Indices start at 0, so 4 specifies the pig.
JComboBox myList = new JComboBox(myStrings);
muList.setSelectedIndex(4) ;
myList.addActionListener(t his);
//Create the combo box, select item at index 4.
//Indices start at 0, so 4 specifies the pig.
JComboBox myList = new JComboBox(myStrings);
muList.setSelectedIndex(4)
myList.addActionListener(t
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And rendering?
ASKER
Thanks, everyone for responding..
thanassis, i've have actually used array only. but
i thought there must be a better way (or simple way)
to do it.
I was expecting a one line answer (any method )
which could serve my purpose. Any how it works.
thanks everyone...
thanassis, i've have actually used array only. but
i thought there must be a better way (or simple way)
to do it.
I was expecting a one line answer (any method )
which could serve my purpose. Any how it works.
thanks everyone...
So if you add
new Employee("Joe Doe", "0001")
what does it say in the combo?
new Employee("Joe Doe", "0001")
what does it say in the combo?
JComboBox uses the toString() so, in my example combined with CEHJs data it should say "Joe Doe" in the JComboBox
Marko
Marko
OK ;-)
ASKER
html code alone & say where same kind of
thing is possible in JComboBox.
Thanks
Arru_in