File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


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