Is it possible to place a child component inside a JButton
and make it transparent to a subset of mouse events so that:
- The child component receives
MouseMotionEvent
s (so it can respond by modifying a displayed image) - Clicking still depresses the
JButton
"behind" the child component
If you add the child component to the button but make no other changes, clicking in the area occupied by the child does not activate the button.
I know this can be achieved by creating a new class that extends JButton
but I would prefer to use a child component which has already been written.
Note: this is purely for cosmetic reasons. The child component only changes its own appearance. It does not perform any other actions in response to clicks. There is just one Action
, triggered by the button in the normal way.