Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

how can i implement the method createCustomCursor

lwiqlwiq Posts: 15Member
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!!!!!!!!

Comments

  • pahpah Posts: 83Member
    : 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

    [code]

    private void changeCursor(){
    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    }
    [/code]

    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....

  • lwiqlwiq Posts: 15Member
    : : 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
    :
    : [code]
    :
    : private void changeCursor(){
    : setCursor(new Cursor(Cursor.WAIT_CURSOR));
    : }
    : [/code]
    :
    : 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!!!!!


  • pahpah Posts: 83Member
    SO if you want a custom cursor you can create a curor with the
    toolkit class

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


    [red]cursor[/red] --> [blue]the image to display when the cursor is activated[/blue]

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

    [red]naem[/red] --> [blue]a localized description of the cursor, for JAVA Accessibility use[/blue]
  • pahpah Posts: 83Member

    : 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!!!
  • lwiqlwiq Posts: 15Member
    : SO if you want a custom cursor you can create a curor with the
    : toolkit class
    :
    : java.awt.Toolkit.getDeafaultToolkit().createCustomCursor(Image [red]cursor[/red],Point [red]hotSpot[/red],String [red]name[/red]);
    :
    :
    : [red]cursor[/red] --> [blue]the image to display when the cursor is activated[/blue]
    :
    : [red]hotSpot[/red] --> [blue]the x and y of the large curors hot spot;
    : the hotspot values must be less than the dimension returned by getBestCursorSize[/blue]
    :
    : [red]naem[/red] --> [blue]a localized description of the cursor, for JAVA Accessibility use[/blue]
    :


    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
  • pahpah Posts: 83Member
    : : SO if you want a custom cursor you can create a curor with the
    : : toolkit class
    : :
    : : java.awt.Toolkit.getDeafaultToolkit().createCustomCursor(Image [red]cursor[/red],Point [red]hotSpot[/red],String [red]name[/red]);
    : :
    : :
    : : [red]cursor[/red] --> [blue]the image to display when the cursor is activated[/blue]
    : :
    : : [red]hotSpot[/red] --> [blue]the x and y of the large curors hot spot;
    : : the hotspot values must be less than the dimension returned by getBestCursorSize[/blue]
    : :
    : : [red]naem[/red] --> [blue]a localized description of the cursor, for JAVA Accessibility use[/blue]
    : :
    :
    :
    : 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
    :

    [code]
    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);
    [/code]

    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

  • lwiqlwiq Posts: 15Member
    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
  • pahpah Posts: 83Member
    : 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.


    [code]

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

    [/code]

  • lwiqlwiq Posts: 15Member
    you deserva a big botle of wine or beer

    thanks man!!!!!
Sign In or Register to comment.