Paul Clapham wrote:
The API docs wrote:Returns the cell index closest to the given location in the list's coordinate system. To determine if the cell actually contains the specified location, compare the point against the cell's bounds, as provided by getCellBounds. This method returns -1 if the model is empty.
Paul Clapham wrote:
Steve Datz wrote:I still dont understand why clicking the empty space in the jList auto selects the last item in the list.
Which other item would you expect it to select?
Oh, I get it, you want it to not select any item if you didn't click on an item. I looked in the JList documentation and it says
The Docs wrote:Use the locationToIndex method to determine what cell was clicked.
It gives an example too:
What that does if you click in a blank area, I don't know but you can adapt that code and try it out.
Paul Clapham wrote:But I did look at the video and it looks like you're trying to click in an empty area of the JList and cause a "Create" dialog to pop up. Wouldn't it be easier to just have a "Create" button to do that? It could go directly above the JList.
Edit: Put, say, a red border around the JList. Then you'll see what screen real estate the JList actually covers. You may find that you're clicking on the background of the JScrollPane instead.
Rob Camick wrote:Where is your SSCCE?