This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

Builderboy2005
Builderboy2005 presents ...

2011/4/18

Advanced Mouse Control

With the help of some people on the Discussion forums, I have created a very small demo scenario that demonstrates how to change the image of the mouse cursor in Greenfoot, as well as how to read from the Scrollwheel

If you look at the source code, you will notice that the Image of the mouse that I am using is actually an actor. This is because not all computers support full color on mouse Images and so I merely disable the mouse image entirely and substitute with an Actor image.

Both of these exploits rely on a tricky piece of code provided by Davmac, and there is no guerentee that they will continue to work in future versions of Greenfoot.

Enjoy the code and use it in all your Greenfoot Scenarios :D

10692 views / 19 in the last 7 days

10 votes | 0 in the last 7 days

Tags: mouse demo with-source

open in greenfoot
Your browser does not support the canvas tag.
All fixed :] I tend to write these descriptions pretty quick, and without the luxury of spell-check :P
bournebourne

2011/11/12

I just saw this and got excited to implement scrolling through something such as a page vertically. But I don't see a way to also scroll horizontally. Don't know what that would consist of. On a track pad on my mac I can scroll vertically and horizontally with similar motions. And I believe on a typical mouse, when you press in the scroll wheel you can do the same thing.
bournebourne

2011/11/12

Works vertically nicely though =)
JetLennitJetLennit

2013/4/25

My normal mouse hovers over the dot
JetLennitJetLennit

2013/4/25

Scratch that
Super_HippoSuper_Hippo

2017/6/22

Is there any way to set it back to default? If I want to use it in one world (at least similar as how you have it), but change from that world to another, how to I get the original cursor back (without clicking on reset and set the world manually)?
YehudaYehuda

2017/6/22

To set the cursor back to the default cursor you can use the following (in this scenario where all the imports already exist). panel.setCursor(null);
YehudaYehuda

2017/6/22

I used that line of code in my Scores class in my screenSize scenario where I changed the cursor during loading.
YehudaYehuda

2017/6/22

@Hippo See here: http://docs.oracle.com/javase/8/docs/api/java/awt/Component.html#setCursor-java.awt.Cursor-
Super_HippoSuper_Hippo

2017/6/23

Thank you!

See all comments

Want to leave a comment? You must first log in.

Who likes this?

Yehuda fejfo Vellyxenya limefortheworld Upupzealot SPower pewing0717 bourne Wyatt915 MathManiac