Results 1 to 5 of 5

Thread: Changing the Cursor shape in Java

  1. #1
    Join Date
    Nov 2009

    Changing the Cursor shape in Java

    Hi, I want to change my Cursor Shape while making my own project, so that it will make impression on the person who will check my project. Just, give me any code or the method from which I can do this. Please, help me as soon as possible. I need this urgently. As I have to submit my project as soon as possible. So, reply as soon as possible.

  2. #2
    Join Date
    Apr 2008

    Re: Changing the Cursor shape in Java

    Hi, the code below will help you to change the cursor shape in java.

    import java.awt.*;
    import java.awt.event.*;
    public class ChangeCursorShape
    	public static void main(String[] args) 
    		Frame frame = new Frame("Change cursor");
    		Panel panel = new Panel();
    		Button b1 = new Button("Ok");
    		Button b2 = new Button("Cancle");
    		Cursor cursor1 = b1.getCursor();
    		Cursor cursor2 = b2.getCursor();
    		frame.addWindowListener(new WindowAdapter()
    			public void windowClosing(WindowEvent we)

  3. #3
    Join Date
    May 2008

    Re: Changing the Cursor shape in Java

    I have created one script with the name Change Cursor which will help you to change a viewers cursor to whatever style you choose.

    Cursor shapes:
    Hand = Hand,
    Crosshair = Crosshair,
    Text = Highlight Text Cursor,
    Wait = Hour Glass,
    Move = 4Arrows,
    Help = ?,
    Arrow = the arrow
    n-resize "for up",
    s-resize "for down",
    e-resize "for right",
    w-resize "for left",


    <!-- Begin Style Code -->
    <!-- End Style Code -->

  4. #4
    Join Date
    Apr 2008

    Re: Changing the Cursor shape in Java

    Hi, you can change cursor shape using the Cursor class and setCursor() method in java. I have tried this and it is working. So, to change the cursor you need to use the following code:

     Cursor hourglassCursor = new Cursor(Cursor.WAIT_CURSOR);
    To set the cursor back to it's "default" shape use following code:

    Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);
    Constants for the shapes are available in the java.awt.Cursor class which are as follows:

  5. #5
    Join Date
    May 2008

    Re: Changing the Cursor shape in Java

    Hi, you want to change the cursor to show the user that something is different. Basically, each cursor is attached to a component. You can make change in cursor only if it is over the component that has set it. There are a number of predefined cursors. The look and feel of each cursor changes with the system to system.

    After you call a component's setCursor(...) method, the cursor will be changed. The parameter to setCursor(. . .) is a Cursor object.

Similar Threads

  1. Cursor Shape And Size
    By hatred in forum Windows XP Support
    Replies: 3
    Last Post: 26-09-2011, 07:20 PM
  2. Replies: 4
    Last Post: 22-09-2011, 07:31 PM
  3. Shape interface of java
    By Gajananvihari in forum Software Development
    Replies: 4
    Last Post: 09-03-2010, 05:08 PM
  4. Changing the Color Theme in Java
    By NIcaBoy in forum Software Development
    Replies: 4
    Last Post: 14-02-2010, 03:23 AM
  5. Changing A Mouse Cursor using C# Code.
    By Braze in forum Software Development
    Replies: 2
    Last Post: 03-01-2009, 07:38 PM

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Page generated in 1,721,159,857.64690 seconds with 17 queries