setCursor on container without it changing cursor of sub components

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-05-31T20:02:23Z Indexed on 2010/05/31 20:33 UTC
Read the original article Hit count: 184

Filed under:

JPanel panel = new JPanel(null); panel.setSize(400, 400); panel.add(new JButton("Test")); panel.setCursor(Cursor.getCursor(Cursor.SOMETHING_SOMETHING_CURSOR));

The panel will have a custom cursor, but I don't want the button to have a custom cursor. I don't want to have to set the cursor of every sub component, because in my application I have many and I don't want to litter the code with setCursor statements.

Is there a way, like overriding a method on the JPanel or something? A "contains" method somewhere is used to determine if a cursor needs to be set. Could I fool it into thinking the mouse is not in the container if it's really in a sub component? Any other nifty little trick?

© Stack Overflow or respective owner

Related posts about java