remove an Item from a JList

I抦 working now with the new jdk1.5.0 and I don抰 see any way to remove an Item from a JList with the methods shown in that class. I will try to illustrate what I want with an example:

copyJList =new JList();

add(new JScrollPane( copyJList ) );

colorJList =new JList( colorNames );// holds names of all colors

add(new JScrollPane( colorJList ) );// add list with scrollpane

copyJButton =new JButton("Copy >>>" );// create copy button

copyJButton.addActionListener(

new ActionListener()// anonymous inner class

{

// handle button event

publicvoid actionPerformed( ActionEvent event )

{

// place selected values in copyJList

copyJList.setListData( colorJList.getSelectedValues() );

[b]// delete selected values from colorJList

colorJList.remove( copyJList.getSelectedIndex() );[/b]

}// end method actionPerformed

}// end anonymous inner class

);// end call to addActionListener[code]

[/code]

[1740 byte] By [estefanoa] at [2007-10-3 3:04:10]
# 1
Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/list.html]How to Use Lists[/url] for a working example of adding and removing items from a list.
camickra at 2007-7-14 20:54:09 > top of Java-index,Desktop,Core GUI APIs...