JComboBox to string

Posted by gabrielle fregil on Stack Overflow See other posts from Stack Overflow or by gabrielle fregil
Published on 2012-10-06T03:18:36Z Indexed on 2012/10/06 3:37 UTC
Read the original article Hit count: 149

Filed under:
|

I have a String array of names, and then I added it into an editable JComboBox.

The user can either pick his/her name from the choices or just input his/her name if not in the choices.

How do I put the user input into a new string variable?

   String [] chooseName = { Mark, John, Allison, Jessica };
   JComboBox combo = new JComboBox (chooseName);
   combo.setEditable(true);

   String chosenName =  /*  how do i place what the user inputed here? */

© Stack Overflow or respective owner

Related posts about java

Related posts about combobox