Sophia Dever

Greenhorn
+ Follow
since Sep 18, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sophia Dever

It's working!

After some more research, I realized I needed to import javax.swing.event.ListSelectionListener and javax.swing.event.ListSelectionEvent, and implement ListSelectionListener.

A final Thank You to everyone for their help--I hope to figure out some more about using Java forums over time.
13 years ago
But the original program didn't have a main method--it was a class used in another program.

Should I put in a main method anyway? Or is it possible that that was affecting/causing the error?
13 years ago
You're right about the subject line. Sorry, I always get the JScrollPane and the JList confused.

Here is the full test program:



Obviously in a full program this would include adding the list to the frame and displaying, but this is the relevant code.

All I want is to be informed when someone clicks on one of the options.

Thanks for bearing with me!
13 years ago
I'm trying to register to get events from a JList The JList itself works fine; after defining "racelist", I say:



When I compile, it gives me the following error:

test.java:18: addListSelectionListener(javax.swing.event.ListSelectionListener) in javax.swing.JList cannot be applied to (test)
racelist.addListSelectionListener(this);
1 error


So is that not the right way? It's what Head First Java says to do.

(Edited because of confusion between JList and JScrollPane.)
13 years ago