Question:

What is the procedure to change the Cursor Image in Java?

by Guest23092413  |  1 year, 2 month(s) ago

0 LIKES UnLike

I am a school student and need to give presentation on the topic procedure to change the Cursor Image in Java?

 Tags: Change, cursor, Image, Java, procedure

   Report

1 ANSWERS

  1. Guest23097324

     Java encompasses structures for conceiving desktops and organizing graphical applications. When you precede your mouse over a Java desktop window, it will use a pre-defined cursor likeness that restores the present mouse pointer icon. You can burden a made-to-order cursor likeness in Java if you desire to change the method of the cursor when it passes over your application's window.
    1: Open your Java application in a text editor or your preferred Java IDE and locate the file for the application window.
    2: Add a new line of text. Type:
    Toolkit tk = Toolkit.getDefaultToolkit();
    Image img = toolkit.getImage("mypicture.gif");
    3: Replace "mypicture.gif" with the path of the file you would like to use as an icon. It must be a valid image file.
    4: Create your cursor hot spot. This is the initial starting location of the cursor, and in most programs it will be at "0,0" which is the upper-left corner of the screen. Type:
    Point hotSpot = new Point(0,0).
    5: Create your cursor. Type "Cursor crsr = toolkit.createCustomCursor(img,hotSpot, "Name to Call Cursor");" without quotation marks on its own line. Replace "Name to Call Cursor" with a friendly name for the cursor.
    6: Display your cursor. Type "set Cursor (cursor);" on its own line.
    7; Save your document in your editor. You have now changed the cursor image in your program.

Question Stats

Latest activity: 1 year, 2 month(s) ago.
This question has been viewed 157 times and has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions