GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Select multiple items in JScrollpane while pressing Control Key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Select multiple items in JScrollpane while pressing Control Key" Watch "Select multiple items in JScrollpane while pressing Control Key" New topic
Author

Select multiple items in JScrollpane while pressing Control Key

Joseph Labrousse
Greenhorn

Joined: Nov 12, 2004
Posts: 2
Can anyone help me with the codes to select multiple items in a list using the control key?
Thanks
Joseph
Kriti Garg
Ranch Hand

Joined: Sep 13, 2004
Posts: 50
Hi,

yes u can select muliple items using cntrl or shift keys by getting the selected items of the list and iterating them ,like this...

......Code.........

Object obj[] = List.getSelectedValues();
int length = List.getSelectedValues().length;
if (length != -1) {
for (int i = 0; i < length; i++) {
///ur logic

}
}

Bbye
 
GeeCON Prague 2014
 
subject: Select multiple items in JScrollpane while pressing Control Key