rimmer0007
asked on
JCombobox question
i m trying to convert def.getSelectedIndex() to a String is it possible to do that? i m trying it below but get a cast error can anyone help
private String string[] = {"Default", "Swing"} ;
def = new JComboBox(string);
String index = (String)def.getSelectedInd ex();
thxs
private String string[] = {"Default", "Swing"} ;
def = new JComboBox(string);
String index = (String)def.getSelectedInd
thxs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ahh because getSelectedIndex returns an INT
yes, and if you want the text,
def.getSelectedItem();
;)
def.getSelectedItem();
;)
ASKER
i m doing a System.out.println(index);
why is it printing out the number and not the string "Default" "Swing"