Re: Combo boxes and JList
Michael Dunn wrote:
"Knute Johnson" <nospam@rabbitbrush.frazmtn.com> wrote in message
news:Imk1j.4019$xP4.1821@newsfe18.lga...
Michael Dunn wrote:
<christopher_board@yahoo.co.uk> wrote in message
news:e8945374-5ec3-41fc-bd4e-4fe2706e93d2@y5g2000hsf.googlegroups.com...
Hi all.
I am currently developing a java application which has a combo box
that lists room rumbers and a JList which lists the computer names.
When I select a room in the combo box I want the data in the JList to
change so it only shows the computer name that starts with the room
number from the combo box.
How would I go about doing this.
in the combo's listener, change the list's model
DefaultListModel newModel = new DefaultListModel();
newModel.addElement("Computer Name");
newModel.addElement("Something else");
list.setModel(newModel);//where list is the JList
Do you think he wanted to know how to change content of the JList or how to make a JList with one
visible element show that element on a change in the JComboBox?
I read it that his current JList shows all computer names, and on selection
of a room from the combo, the JList is to be filtered to show only those
computers in that room. (Probably wrong - usually am)
I have the same problem :-).
--
Knute Johnson
email s/nospam/knute/