This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JList, clicking empty space selects last item Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList, clicking empty space selects last item" Watch "JList, clicking empty space selects last item" New topic
Author

JList, clicking empty space selects last item

Leo Deegan
Greenhorn

Joined: Jun 15, 2004
Posts: 12
I hope this is descriptive enough:

I have a JList in a JScrollPane and the list of items in the JList is not enough to fill the whole viewable area. (I have like 3 items, but there's enough space for, say, 10 items.)

Pretend the first item in the list is already selected. When I mouse-click the empty space below the last item in the list, the last item in the list becomes selected. I don't want this to happen.

I want mouse clicks on the empty space below the last item to be ignored. How can I accomplish this?

Thanks in advance
--Leo
Leo Deegan
Greenhorn

Joined: Jun 15, 2004
Posts: 12
I figured out a solution:

Make a JPanel with a BorderLayout.
Add the JList to the JPanel using BorderLayout.NORTH.
Put the JPanel in the JScrollPane.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JList, clicking empty space selects last item
 
Similar Threads
Right Click List Selection
Changing the text colour of JList items
problem selecting JList item
JList
Need help with JList selection modes