Forums Register Login
JList, clicking empty space selects last item
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
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.
Onion rings are vegetable donuts. Taste this tiny ad:
Rocket Oven Kickstarter - from the trailboss

This thread has been viewed 1974 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 17, 2018 02:04:31.