yup. i got it!!
1) To get d item from dorpdown menu:
String tvalue_str=(String)t2.getSelectedItem();
2) this is d way i write to display the selected item :
int3.append("Value of T ="+tvalue_str+"\n");
thanks sennat_26
I would like to add that in the same way you added String to the JComboBox, you can add objects:
class SomeObject {
// many attributes
}
JComboBox t2 = new JComboBox();
// add some SomeObject objects to the JComboBox
SomeObject so = (SomeObject)t2.getSelectedItem();
Also what will be displayed at the JComboBox will be determined by the toString method of SomeObject class. So don't forget to override it:
class SomeObject {
// many attributes
public Stirng toString() {
return ""; // return whatever you want to be displayed at the options of ComboBox
}
}
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448