This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Select multiple items in JScrollpane while pressing Control Key