• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mouse Cursor Not Changing

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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());
reply
    Bookmark Topic Watch Topic
  • New Topic