开发者

setCursor on container without it changing cursor of sub components

JPanel panel = new JPanel(null);
panel.setSize(400, 4开发者_JS百科00);
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?


Could I fool it into thinking the mouse is not in the container if it's really in a sub component?

Maybe on your panel you can use a MouseListener. On mouseEntered you set your cursor. On mouseExited, you set the cursor to null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜