Hi,
Just add my obversation. An editable combobox (actually
its model) does not save the user input to its internal list
until the user hits "return". If the user entered something in
the input field, but did not press "return", getSelectedItem()
will return null.
Using (JComboBox).getEditor().getItem() is more reliable, if
you want to capture the user's input without his/her extra key
stroke.
Mingjian Song
> -----Original Message-----
> From: Ravi Prakash [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, April 26, 2001 1:01 PM
> To: Roman Novikov
> Cc: [EMAIL PROTECTED]
> Subject: Re: JComboBox
>
> Hi,
>
> JComboBox cb = new JComboBox().
> cb.setEditable(true);//which allows to enter values in combobox
> Integer item = (Integer)cb.getSelectedItem();
> int value = item.intValue();
>
> for further improvements go read swing tutorial in www.java.sun.com
>
> ravi
>
> Roman Novikov wrote:
>
> > Hello!
> >
> > Please, help me to use an editable subj. How can i get the Values
> > from it?
> > I have a JComboBox with String values in it and I want to enter
> > and get int values. Is it possible?
> > Any sample would be great.
> >
> > Thanks.
> >
> > Sincerely, 26.04.01
> > Roman
> >
> > ("`-''-/").___..--''"`-._
> > `6_ 6 ) `-. ( ).`-.__.`)
> > (_Y_.)' ._ ) `._ `. ``-..-'
> > `--'_..-_/ /--'_.' ,'
> > (ll).-'' (((!.' ((!.-'
> >
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing