Question

Possible Duplicate:
Find the JTable cell and paint it

This is my Rectangle class object.

 Rectangle cell = table.getCellRect(row, column, false);

Now I want to highlight it on mouse press event and again back to normal to mouse realeased event.

Was it helpful?

Solution

There are multiple ways to add the feature.

The first one is implementing custom Renderer/Editor for the cell. The renderer keeps row/column and isPressed state. When mouse is pressed renderer state is set and reset on release.

Another way is to override JTable's paintComponent() method to draw the Rectangle with e.g. semi-transparent color.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top