Power Table OnMouseClick Cell Color Change

You cannot directly change the cell color from the mouse event. You must store your styling information in a custom property (perhaps another dataset with the same dimensions as your table data). The mouse event can only update that custom property.

The configure cell method is called automatically by the component whenever java swing needs to "paint" that cell. Have that method look up the desired color in the custom property and return that.

Changing a custom property is one of the triggers that causes Swing to repaint, so the mouse click updating a custom property will naturally cause the configureCell method to be called shortly.

(configureCell is called really often--any time the table is obscured by something then unobscured, it has to be repainted. Java takes care of this, by you must have the styling data hanging around.)

1 Like