Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


awt.List ItemEvent source...

Posted on 2003-02-28
Medium Priority
Last Modified: 2010-07-27
This is for the awt.List:

I want to do things accodring to which item(s) is selected in a List. So I want to mark the selected items in a simple way, and then use that info when a button is pressed for example.

The ItemListener though that I put, receives ItemEvent-s coming from the List itself, not the items in the list. The only way I can see the actual items of the list, is the ItemEvent.paramString(), which is far from useful.

Is there a reasonable way to do it?? (To get the index number of the list item selected/pressed)

Question by:piou
  • 3
LVL 92

Accepted Solution

objects earned 480 total points
ID: 8046396
int index = list.getSelectedIndex();
String item = list.getSelectedItem();
LVL 92

Expert Comment

ID: 8046400
The ItemEvent also contains details about the event.

Author Comment

ID: 8046410
Damn I'm bad! Damn you're good! :) Why didn't I care to look at the List methods??? :)
LVL 92

Expert Comment

ID: 8046439
Javadoc is your friend :-)

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question