tiger0516
asked on
JList question
Hi folks,
I have a JList
String[] name={......}
JList j=new JList(name)
How shall I do in the ListSelectionListener so that when I click one list item, Java will print that "xxx (the name of the selected item) is selected"
thanks
I have a JList
String[] name={......}
JList j=new JList(name)
How shall I do in the ListSelectionListener so that when I click one list item, Java will print that "xxx (the name of the selected item) is selected"
thanks
or o/wise:
public void valueChanged(ListSelection Event e)
{
JList list = (JList) e.getSource();
System.out.println(list.ge tSelectedI tem());
}
public void valueChanged(ListSelection
{
JList list = (JList) e.getSource();
System.out.println(list.ge
}
ASKER
I use Eclipse. It says the method getSelectedItem()) is undifined for the type JList.
(I use your 2nd comment)
(I use your 2nd comment)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
public void valueChanged(ListSelection
{
System.out.println(j.getSe
}