Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (744)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (825)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Hiding the cursor  (Read 3176 times)
0 Members and 1 Guest are viewing this topic.
Offline Torquemada

Senior Newbie




Java games rock!


« Posted 2004-09-22 20:31:04 »

Hi

How do I hide the mouse cursor in awt/swing? I would like to draw my own graphic.

Would it be better to hide the cursor and draw an image based on the cursor, or to create a custom mouse cursor and set it to that?

Thanks
Offline ogreblue

Junior Newbie




OgreBlue rocks!


« Reply #1 - Posted 2004-09-22 21:27:02 »

Image cursorImage = Toolkit.getDefaultToolkit().getImage("xparent.gif");
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImage, new Point( 0, 0), "" );
setCursor( blankCursor );

I hope this works, it did for me. If you didn't want a cursor at all, make xparent transparent. This may not be the best way but for small apps it may be ok. Worth a try.
Offline Malohkan

Senior Devvie




while (true) System.out.println("WOO!!!!");


« Reply #2 - Posted 2004-09-22 22:18:51 »

I create an Image in code with a 1x1 transparent pixel.  No need to save that to a file, just code it.

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Torquemada

Senior Newbie




Java games rock!


« Reply #3 - Posted 2004-09-22 23:23:55 »

Thanks, that's what I needed Smiley
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #4 - Posted 2004-09-23 16:58:33 »

setCursor(Toolkit.getDefaultToolkit().createCustomCursor(new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB),new Point(0,0),""));

Wink

弾幕 ☆ @mahonnaiseblog
Offline ozak

Junior Devvie




Java demon has no respect for bad code!!!


« Reply #5 - Posted 2004-09-23 18:37:52 »

Although OS X happily ignores this Smiley

Want to do multiplayer? Why not try my free Socky socket server?
It's scriptable through JavaScript!
Check it out at http://www.furi.dk/socky
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #6 - Posted 2004-10-04 06:45:56 »

Quote
Although OS X happily ignores this Smiley


oNyx's version works for me under OS X with a JOGL canvas.  The cursor change is the last thing that happens when loading (and the canavas is visible when it is hidden).

If the application loses focus, the cursor reverts back to the default when focus is regained and has to be manually reset.

Will.

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #7 - Posted 2005-12-12 06:57:49 »

This mac issue (clearly a bug) sucks so much. I'm having that problem with fuzetsu on mac.

Was that ever fixed? Guess not.

And why isnt there a default cursor for that. Its not that unusual, is it? Ah ok... found the answer myself...

"We've decided against doing this: its merely a hack so that the customer can
then draw their own cursor. What they really want is a way to set the cursor
to an arbitrary bitmap, which we promise to do in 1.2."

Yea, right... what I really want... creating some transparent image looks more like a hack to me.

* oNyx throws the first rock

9+ years later and its still an issue. I cant believe it. Reporting bugs is such a bad joke when it comes to java. (Thats one of the two things which suck about java... the other one are distribution issues.)

弾幕 ☆ @mahonnaiseblog
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #8 - Posted 2005-12-14 03:47:18 »

I find the bug reports are not a joke.  You have to realize just how huge Java is and that the people evaluating the bug reports often are seeing things from a different perspective and may not get the point.   

I can easily see how the evaluator came to the conclusion that  custom cursors were the "real" problem, and quite frankly I think I would come to the same evaluation.  It does solve both problems... getting user definable cursors AND hiding the cursor.  I don't think it is a hack, it is in fact a clean solution.  Why have a way to set the cursor to a custom image and a different way to set the cursor to not appear?  At the OS level there it could be that cursor hiding is implemented using a "empty" cursor image anyway Smiley


Have you filed a bug report with Apple about the cursor reset on focus gained?

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #9 - Posted 2005-12-14 11:36:33 »

>I find the bug reports are not a joke. You have to realize just how huge Java is[...]

I know how big java is and I also know that that's the reason why it takes years (till forever) to fix things.

>Why have a way to set the cursor to a custom image and a different way to set the cursor to not appear?

There are a lot of predefined cursors. Why not have a predefined one for this case?

>Have you filed a bug report with Apple about the cursor reset on focus gained?

No. I dont have a mac myself. Writing a bug report would be useless. They would decide that it lacks detail and it would go directly to the trash bin like my other bug report. I rather bitch about the whole issue... its more fun (and equally useless).

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #10 - Posted 2005-12-15 03:08:04 »

There are a lot of predefined cursors. Why not have a predefined one for this case?

Yes, they should have that.  Is there an enhancement request?


I would file bugs anyway... there is nothing I hate more that users that don't tell me what is wrong with my code.. they just bitch about stuff not working.. but they won't tell the people that can do something about it.  If nothing happens, fine, not every one of person X's problems can be a top priority... but if you haven't bothered to ask for a fix at all then you shouldn't expect to get one.

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #11 - Posted 2005-12-15 04:52:22 »

Instead of telling me the same stuff you already told me 2 years ago you could have written a bug report yourself.

If something is useless and no fun at all (like burning my fingers on a hot plate), I stop doing it. End of story.

弾幕 ☆ @mahonnaiseblog
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #12 - Posted 2005-12-15 07:19:26 »

setCursor(Toolkit.getDefaultToolkit().createCustomCursor(new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB),new Point(0,0),""));

I believe that it isn't guaranteed that the BufferedImage will start off transparent (since Java 1.1).  Enabling Quartz on OS X 10.4 certainly changing the default fill for me.  It is probably worth considering setting the background colour to transparent & using clearRect on it.


Edit: Knew I'd seen it stated somewhere Smiley

Quote
clearRect

public abstract void clearRect(int x,
                               int y,
                               int width,
                               int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface. This operation does not use the current paint mode.
Beginning with Java 1.1, the background color of offscreen images may be system dependent. Applications should use setColor followed by fillRect to ensure that an offscreen image is cleared to a specific color.

Time flies like a bird. Fruit flies like a banana.
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (150 views)
2017-09-30 02:57:34

theagentd (225 views)
2017-09-26 18:23:31

cybrmynd (304 views)
2017-08-02 12:28:51

cybrmynd (291 views)
2017-08-02 12:19:43

cybrmynd (300 views)
2017-08-02 12:18:09

Sralse (292 views)
2017-07-25 17:13:48

Archive (980 views)
2017-04-27 17:45:51

buddyBro (1106 views)
2017-04-05 03:38:00

CopyableCougar4 (1685 views)
2017-03-24 15:39:42

theagentd (1433 views)
2017-03-24 15:32:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!