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)
Thanks, Damien
Please refer below code snippet, and you'll get the solution
If you want to only show the specific cell, all you have to do is change the column param in the params of getValueAt(...) method to a specific column which contains that cell
Try getCellRect
Just use below code while creation of JTable object.
Use the following code to get the value for the correct row if using RowSorter:
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.