• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JList, clicking empty space selects last item

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic