Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how can i implement the method createCustomCursor Posted by lwiq on 14 Mar 2007 at 2:47 AM
i try for 2 days now to implement into an applet this method (i want to change the look of the mouse with an image)
can you help me with an easy source code that implements that???
anticipated thanks to anyone who can help me!!!!!!!!

Report
Re: how can i implement the method createCustomCursor Posted by pah on 14 Mar 2007 at 3:11 AM
: i try for 2 days now to implement into an applet this method (i want to change the look of the mouse with an image)
: can you help me with an easy source code that implements that???
: anticipated thanks to anyone who can help me!!!!!!!!
:
:

try the setCourser methode

example


private void changeCursor(){
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
}


Some cursors which you can set

Cursor.CROSSHAIR_CURSOR
Cursor.DEFAULT_CURSOR
Cursor.MOVE_CURSOR
Cursor.TEXT_CURSOR
Cursor.WAIT_CURSOR

This are some of the cursor which you can set, but how you create your own cursor i dont now. Maybe this helps you....

Report
Re: how can i implement the method createCustomCursor Posted by lwiq on 14 Mar 2007 at 3:18 AM
: : i try for 2 days now to implement into an applet this method (i want to change the look of the mouse with an image)
: : can you help me with an easy source code that implements that???
: : anticipated thanks to anyone who can help me!!!!!!!!
: :
: :
:
: try the setCourser methode
:
: example
:
:
: 
: private void changeCursor(){
:     setCursor(new Cursor(Cursor.WAIT_CURSOR));
: }
: 

:
: Some cursors which you can set
:
: Cursor.CROSSHAIR_CURSOR
: Cursor.DEFAULT_CURSOR
: Cursor.MOVE_CURSOR
: Cursor.TEXT_CURSOR
: Cursor.WAIT_CURSOR
:
: This are some of the cursor which you can set, but how you create your own cursor i dont now. Maybe this helps you....
:
:

tkx, BUT i want to change the default mouse icon with an image, to create my own cursor (i want to create a game and i need a crosshair different) pls help!!!
i know its about using Toolkit.getDefaultToolkit.createCustomCursor(cursor image, new Point(x,y), "myCursor") but i cannot implement this under an applet!!!!!


Report
Re: how can i implement the method createCustomCursor Posted by pah on 14 Mar 2007 at 3:29 AM

: tkx, BUT i want to change the default mouse icon with an image, to create my own cursor (i want to create a game and i need a crosshair different) pls help!!!
: i know its about using Toolkit.getDefaultToolkit.createCustomCursor(cursor image, new Point(x,y), "myCursor") but i cannot implement this under an applet!!!!!
:
:
:
I didnt created now my own Cursor but i can change the cursor with the setCursor() methode!!!
Report
Re: how can i implement the method createCustomCursor Posted by pah on 14 Mar 2007 at 3:21 AM
SO if you want a custom cursor you can create a curor with the
toolkit class

java.awt.Toolkit.getDeafaultToolkit().createCustomCursor(Image cursor,Point hotSpot,String name);


cursor --> the image to display when the cursor is activated

hotSpot --> the x and y of the large curors hot spot;
the hotspot values must be less than the dimension returned by getBestCursorSize


naem --> a localized description of the cursor, for JAVA Accessibility use
Report
Re: how can i implement the method createCustomCursor Posted by lwiq on 14 Mar 2007 at 3:31 AM
: SO if you want a custom cursor you can create a curor with the
: toolkit class
:
: java.awt.Toolkit.getDeafaultToolkit().createCustomCursor(Image cursor,Point hotSpot,String name);
:
:
: cursor --> the image to display when the cursor is activated
:
: hotSpot --> the x and y of the large curors hot spot;
: the hotspot values must be less than the dimension returned by getBestCursorSize

:
: naem --> a localized description of the cursor, for JAVA Accessibility use
:


doesnt work, thats why i ask anyone to implement that method into an easy applet. i thank you for all you did (you are the firt one who ever replie to me) tkx
Report
Re: how can i implement the method createCustomCursor Posted by pah on 14 Mar 2007 at 5:02 AM
: : SO if you want a custom cursor you can create a curor with the
: : toolkit class
: :
: : java.awt.Toolkit.getDeafaultToolkit().createCustomCursor(Image cursor,Point hotSpot,String name);
: :
: :
: : cursor --> the image to display when the cursor is activated
: :
: : hotSpot --> the x and y of the large curors hot spot;
: : the hotspot values must be less than the dimension returned by getBestCursorSize

: :
: : naem --> a localized description of the cursor, for JAVA Accessibility use
: :
:
:
: doesnt work, thats why i ask anyone to implement that method into an easy applet. i thank you for all you did (you are the firt one who ever replie to me) tkx
:

ImageIcon icon = new ImageIcon("[FOLDER]/[FILENAME].gif");
Image a = icon.getImage();

final java.awt.Cursor myCursor =
java.awt.Toolkit.getDefaultToolkit().createCustomCursor(a,new java.awt.Point(8,8),"test");

setCursor(myCursor);


This should work also with a applet!?
The only problem which you should have is to recive or to bundle the image into the applet....so the server should send the applet the picture or you have to bundle the image in the applet then the [FOLDER]/[FILE].* paraemter looks different

Report
Re: how can i implement the method createCustomCursor Posted by lwiq on 15 Mar 2007 at 2:59 AM
k, this is the program:
*********************************
import java.awt.*;
import java.applet.*;
import javax.swing.ImageIcon;

public class mouse extends Applet{

Image b;

public void init() {
ImageIcon icon = new ImageIcon("sani.gif");
Image a = icon.getImage();

final java.awt.Cursor myCursor = java.awt.Toolkit.getDefaultToolkit().createCustomCursor(a,new java.awt.Point(8,8),"test");
setCursor(myCursor);

b=getImage(getCodeBase(),"sani.gif");
}

public void paint(Graphics g)
{
g.drawImage(b,50,50,this);
}
}
***************************************
i can see the picture from paint, but i cannot see the cursor at all
pls another hint???
tks vvvvvvv much
Report
Re: how can i implement the method createCustomCursor Posted by pah on 15 Mar 2007 at 7:51 AM
: k, this is the program:
: *********************************
: import java.awt.*;
: import java.applet.*;
: import javax.swing.ImageIcon;
:
: public class mouse extends Applet{
:
: Image b;
:
: public void init() {
: ImageIcon icon = new ImageIcon("sani.gif");
: Image a = icon.getImage();
:
: final java.awt.Cursor myCursor = java.awt.Toolkit.getDefaultToolkit().createCustomCursor(a,new java.awt.Point(8,8),"test");
: setCursor(myCursor);
:
: b=getImage(getCodeBase(),"sani.gif");
: }
:
: public void paint(Graphics g)
: {
: g.drawImage(b,50,50,this);
: }
: }
: ***************************************
: i can see the picture from paint, but i cannot see the cursor at all
: pls another hint???
: tks vvvvvvv much
:
Have you tried this.



import java.awt.*;
: import java.applet.*;
: import javax.swing.ImageIcon;
: 
: public class mouse extends Applet{
:    
:    Image b;
:    
:    public void init() {
        b=getImage(getCodeBase(),"sani.gif");
:       //ImageIcon icon = new ImageIcon("sani.gif");
:       //Image a = icon.getImage();
:       
:       final java.awt.Cursor myCursor = java.awt.Toolkit.getDefaultToolkit().createCustomCursor(b,new java.awt.Point(8,8),"test");
:       setCursor(myCursor);
:       
:       
:    }
: 
:    public void paint(Graphics g)
:    {
:       g.drawImage(b,50,50,this);
:    }
: }



Report
tanks to PAH Posted by lwiq on 15 Mar 2007 at 1:28 PM
you deserva a big botle of wine or beer

thanks man!!!!!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.