?
Solved

Listeners

Posted on 2005-05-10
9
Medium Priority
?
252 Views
Last Modified: 2010-03-31
I've got a JList within a JScrollPane which is supposed to update another JList/JScrollPane when clicked.

What kind of listener do I use? Tried with ActionListener, but didn't work...

eX.
0
Comment
Question by:Gaute Rønningen
  • 5
  • 2
  • 2
9 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 300 total points
ID: 13968802
>> when clicked.
Don't you mean: when (an item in it is) selected. Then you need a ListSelectionListener
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13968809
If you really mean: when click on it, you need a MouseListener (mouseClicked() method)
0
 
LVL 3

Expert Comment

by:schybert
ID: 13968822
ListSelectionListener or MouseListener.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:schybert
ID: 13968835
Hehe... looks like I was a bit slow...
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13968838
>> to update another JList/JScrollPane when clicked
That's typically the case if list1 contains items that list2 should show the detail(ed item)s of.
In that case you certainly need a ListSelectionListener.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13968845
>> Hehe... looks like I was a bit slow...
;°)
0
 

Author Comment

by:Gaute Rønningen
ID: 13969138
So a sample code would be something like:
list.addListSelectionListener(new ListSelectionListener()...etc. ???
0
 

Author Comment

by:Gaute Rønningen
ID: 13969203
Tried it and that works... Thanks :-)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13969223
Thanks for accepting.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 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