File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Cursor Image on Applet??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Cursor Image on Applet???" Watch "Cursor Image on Applet???" New topic
Author

Cursor Image on Applet???

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi all friends,
Iam facing a problem with changing cusor image on applet.My applet working fine when I run it through command "appletviewer CursorApplet.java" on dos-prompt.But when I call that applet in html file on IE5.5 giving me error [java.lang.noSuchMethod found::createCustomCursor()] and when I tried it on Netscape4.7
it giving me error[java.lang.ClassFormatError:Bad major version number]
I complied my CursorApplet.java by command(javac -target 1.2 CursorApplet.java) for specified the version of JVM.
If any one have any solution for this problem plz extend to me.Any help will be highly appreciated.
Below r my codes:-
CursorApplet.java
===================
import java.awt.*;
import java.applet.*;
/*
<applet code="CursorApplet" width=200 height=200>
</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, "drop");
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
//set the cursor for this applet component
setCursor(cr);
}
}
Html file
=========
<html>
<head>
<title>
Applet Example
</title>
</head>
<body bgcolor="black">
<table><tr>
<td>
<applet code="CursorApplet.class" width=200 height=200>
</applet>
</td>
</tr>
</table>
<body>
</html>
Regards
Bikash :roll:
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Bikash,
Browsers don't support Java 2. You will need to use the Sun Java 2 plug-in in order for you to use Java 2 methods (i.e., createCustomCursor of ToolKit).
Both browsers stopped java support at about 1.1.8.
Regards,
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cursor Image on Applet???