When you select a row within a JComboBox how do you get that row to be printed in a textfield. Am I right in thinking that you use the ItemSelected method? Any help with this would be greatly appreciated.
you need to add a listener to the JComboBox. Either an ItemListener or ActionListner depending on your needs. Experiment with both. When an event is fired call getSelectedIndex() on your combo box to get the selected row. D.
If you want to write to a text field you could that wit
where tf is the name of your textfield and cb is the name of your JComboBox. Ed
The nice thing about Standards is that there are so many to choose from!
Joined: Feb 23, 2004
Just tried out what you said, and I get an error when compiling the code:- setText(java.lang.String) in javax.swing.text.JTextComponent cannot be applied to (java.lang.Object) value.setText(box.getSelectedItem()); where value = textfield and box = jcombobox This wouldn't be that the values in the combo box are obtained from a vector. If so how do I overcome this problem