Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Changing Cursor Image?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Changing Cursor Image??" Watch "Changing Cursor Image??" New topic
Author

Changing Cursor Image??

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi all friends,
I am facing problem with changing cursor image I want to change my cursor image for my website home page for that I write a applet programme it is running fine with "appletviewer" command on dos-prompt but when i call that applet file in html file through applet tag then browser giving me "error:java.lang.noSuchMethod found in java.awt.Toolkit 'createCustomCursor()'".I tried it on IE5,IE5.5 & Netscape4.7 all r giving same error but I couldn't understand why it is giving me this error.Can any one plz tell why this error.Any help will be highly appreciated.
Below r my codes:-
Applet file:-
-------------
import java.awt.*;
import java.applet.*;
public class CursorApplet extends Applet {

public void init() {
//load the image with the Media Tracker
MediaTracker tracker = new MediaTracker(this);
Image cursor = getImage(getCodeBase(), "drop.gif");
tracker.addImage(cursor, 1,16,24);
try {
tracker.waitForID(1);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
Cursor cr = null;
//get the toolkit for this environment
Toolkit tk = getToolkit();
try
{
//this is the x,y coordinates of the image which
//will actually do the "clicking"
Point hotSpot = new Point(1, 1);
//create the custom cursor
cr = tk.createCustomCursor(cursor, hotSpot, "music_note");
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
//set the cursor for this applet component
setCursor(cr);
}
}
html file:-
-----------
<html>
<head>
<title>An Example</title>
</head>
<body bgcolor="black">
<applet code="CursorApplet.class" width=200 height=200>
</applet>
<body>
</html>
Regards
Bikash
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
An idea:
java.awt.Toolkit::createCustomCursor(Image, Point, String) is "since 1.2". So, maybe the browsers you are using are using a JRE less than 1.2.
You could try compiling your code using javac -target 1.1 (and let us know if that improves the situation).
Good Luck.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
It seems to be working fine for me in IE 6 using a JRE of 1.3.
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi Drik,
First of all thanks for ur reply.U told me that I should compile my applet programme with command
"javac -target1.1" but I couldn't understand what it is "target1.1" Can u plz tell me what is it I compiled my applet programme with command "javac FileName.java".And Iam using Sun's jdk1.2.0 Excepting quick reply.
Regards
Bikash
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi Drik,
As per my knowledge IE6 not support JVM then how u can use JRE1.3 with IE6.Plz explain me.
Regards
Bikash
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi drik,
Now I complied my applet programme by below command:-
javac -target 1.2 CursorApplet.java
But When I call that file in html on IE5 then it is giving me error(load:CursorApplet file not found)but I keep that class in samefolder from where Iam running my html file.And when I tried on Netscape4.7 it is giving me error(Applet CursorApplet error:java.lang.ClassFormatError:Bad major version number).Can u plz guide me how I can slove this problem.Eagarly waiting for ur reply.
Regards
Bikash
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Changing Cursor Image??
 
Similar Threads
Slideshow that i created giving me problems!
how to implement customised cursors in appets
Cursor Image on Applet???
Can't run my applet on a html page
Whats wrong with this?