Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Mouse Cursor Not Changing  RSS feed

 
michael byrd
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following:

panel = new JPanel(new BorderLayout());
tb = createToolBar();
p2 = new JPanel();
panel.add(tb, BorderLayout.NORTH);
panel.add(p2, BorderLayout.CENTER);



when a button is clicked in the toolbar i try to change the parents panel mouse cursor to the HAND_CURSOR.


//inside the toolbar class when a button is clicked
getParent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));



...well the cursor is not changing. I know that when you set the cursor for a Container that all subcomponents will get that cursor if their cursor is null...otherwise it wont. So i recursively printed out the children components of the parent, as well as their comp.getCursor() and they all have the HAND_CURSOR...which is expected since I had just set it.

I also tried, recursively setting the cursor for the parent and all children to null

comp.setCursor(null);



...as i recursively set the cursor to null I printed out the result of comp.getCursor(). Sure enough it was always "java.awt.Cursor[Default Cursor]". So, according to the Component.setCursor documentation the cursor wont change for anything in the Container...since its subcomponents have non-null cursors.

Any ideas why it doesnt show up? or how to do it??
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//inside the toolbar class when a button is clicked
getParent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

toolbar class?
I would look to see/verify who is returned by the getParent call
System.out.println(getParent().getClass().getName());
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!