Bug - Fixed Tool tips not displaying in the Store manager

Serin

New member
This is cropped from
http://kolmafia.us/showthread.php?8719-Store-Manager-Revamp

Apparently there are supposed to be tool tips for the "remove item from store" button and the "Price analysis" button.. but they're not showing.

The code shows:
PHP:
removeItemButton.setToolTipText( "remove item from store" );
and
PHP:
searchItemButton.setToolTipText( "price analysis" );
so I guess they are supposed to have tooltips. On windows, I'm not seeing them.

I expect that adding a tooltip will install a MouseListener on the button.
We also add a MouseListener - a ThreadedListener - to the buttons.
Supposedly, a Component can have multiple MouseListeners.
 

Veracity

Developer
Staff member
I've looked at this, and, near as I can tell, the issue is that the two JButtons are not actually installed as buttons in the frame; they are part of the data. The table of items in your store is a table of lists of objects: Item Name, Price, Lowest, Quantity, Limit, remove button, search button. The last two are JButtons with icons, but are not actually installed as buttons. Instead, they are implemented via a MouseListener, which does an action when the mouse is clicked on the icon. Since the buttons are simply images on the screen, rather than being hooked into Swing as buttons, the tooltips are ignored.

It is possible to have actual JButtons in table data, but you have to build the code to support that yourself. Here is a Java Example showing how to do that. If we did something like that, we could install real buttons and move the implementation from a MouseListener to an Action of some sort.

Looks like a Project.
 

Veracity

Developer
Staff member
Or...since we have a MouseListener already on the buttons, perhaps we can add something to that: if the mouse moves into the button, set the tooltip on the row, and let the TooltipManager will display it. Here is another Java article about doing something like that.
 

roippi

Developer
Fixed in the new store manager revamp.

For the record, veracity, you were right about the issues involved here: the way JTables work, you are not looking at a JButton - you're looking at a rendered cell that looks like a jbutton, but there's not a component behind it. Clicking it normally doesn't do anything; it's akin to clicking a screenshot of your desktop rather than the actual icons on your desktop.

I ended up implementing something very like your first example, which takes over the cell editor in order to fire events. It's an awful hack, but that's just how JTables work.
 
Top