views:

297

answers:

2

Hello, I need to show a tooltip above (or below :) a cell when the user enter a wrong value in it (see the image below). I have a tooltip, but I need a Point to display it at the right position, so I want to get a cell position. Do you know how to get this?

BUT, if you have a better solution to realize this behaviour, I'm open to all proposition (especially for the fact that the tooltip is not bind with the cell/Jtable/Panel and if I move/close/minmize my window the tooltip is display at the same position)

alt text

Thanks, Damien

+1  A: 

Try getCellRect

Vinodh Ramasubramanian
Yeah! It seems this can respond to my problem, thanks :)Do you know a solution where the tooltip is link to the cell?
Damien
+1  A: 

You have an example of such feature in the Swing components visual guide.

Edit: In fact, it is not really a tooltip that you need here, as the tooltip need to have the cursor positionned over the cell. You want to display the tooltip even if the cursor is outside the cell, right?

Anyway, an alternative solution is to change the background of the cell when the value entered by the user is invalid (in orange or red for example), and then add a "real" tooltip (using the link I provided) in order to give the user a complete error message.

romaintaz
Yes, it's not a "real" tooltip.Your workaround could be fine. Do you how can I show a (real) tooltip when the user entering a value? (I'm in the setValueAt() method)
Damien