Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList, clicking empty space selects last item

 
Leo Deegan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic