• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing Cursor Image??

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems to be working fine for me in IE 6 using a JRE of 1.3.
 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic