Re: Adding Elments to JComboBox



One way is:
String[] options = { "Bird", "Cat", "Rabbit" };
cmb = new JComboBox(options);

fiqri wrote:
>Hi All,
>
>I am new to java gui. My requirement is to add elements to jcombobox
>with respective values. For an example: I need to display servarl names
>in the list if a list item selected a value or an id assigned to it
>should out put.
>
>in html i can do this
>
><select name=cmb>
> <option value=100>Bird</option>
> <option value=200>Cat</option>
> <option value=300>Rabbit</option>
></select>
>
>if you select "Bird" 100 is displayed
>
>i need to accomplish this task using java and jcombobox.
>
>please help on this.
>
>thankx
.



Relevant Pages

  • Adding Elments to JComboBox
    ... I am new to java gui. ... I need to display servarl names ... i need to accomplish this task using java and jcombobox. ... Prev by Date: ...
    (comp.lang.java.gui)
  • Re: is this feasible? (newbie question)
    ... > however, for my college assessment, I passed the var as asked, but wanted ... but it gets rather deeper into Java GUI ... What you need to do is set an ActionListener on the ... JComboBox, which, on receiving an ActionEvent, gets the currently ...
    (comp.lang.java.programmer)