0 LIKES LikeUnLike
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
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.
Report (0) (0) | 12 years, 8 month(s) ago
Latest activity: 13 years, 1 month(s) ago. This question has 1 answers.