customizing jlist's internal logic for selecting cells

B

B Young

I've written a highly customized JList that lays cells out
horizontally, wrapping, and is editable. This is presenting a problem
with one piece of default JList behaviour that I need to change or
remove and install my own functionality.

My JList can have a lot of white space potentially at the right and
bottom depending on the number of items and preferred sizes, etc.
Well, There is no such thing as a click inside a JList that doesn't
register and select *something*. You can click into what appears to be
never-never-land and guess what, it selects the nearest cell. I have
better logic I'd like to install for when something gets selected, but
how do I get at the default behaviour? What do I remove, override,
etc?

P.S. I've tried overriding "int locationToIndex(Point p)" and making
it work "properly", returning -1 if the mouse click was nowhere near
an actual cell. No good though- doesn't look like its being called by
JList to determine what to select.

Sincerely
Thanks.
 
H

hiwa

I've written a highly customized JList that lays cells out
horizontally, wrapping, and is editable. This is presenting a problem
with one piece of default JList behaviour that I need to change or
remove and install my own functionality.

My JList can have a lot of white space potentially at the right and
bottom depending on the number of items and preferred sizes, etc.
Well, There is no such thing as a click inside a JList that doesn't
register and select *something*. You can click into what appears to be
never-never-land and guess what, it selects the nearest cell. I have
better logic I'd like to install for when something gets selected, but
how do I get at the default behaviour? What do I remove, override,
etc?

P.S. I've tried overriding "int locationToIndex(Point p)" and making
it work "properly", returning -1 if the mouse click was nowhere near
an actual cell. No good though- doesn't look like its being called by
JList to determine what to select.

Sincerely
Thanks.

I believe your event listeners for your JList can control
the issue described here.
 
B

B Young

After some further research, the problem appears to be in BasicListUI.
The code is way too happy to go and find the closest cell even if the
mouse click was far outside of a legitimate cell boundry.

I don't see a way around this though since customizing BasicListUI is
more than I want to get involved with. I can just about as easily
crank out a custom component of some type that mimics the
functionality I want.

Thanks
Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top