• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Hand Cursor

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Our requrement is that whenever mouse is over an image, mouse cursor to be changed to hand cursor.We wrote a programe but couldn't understand as how to use it.
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.Cursor.*;
/* < applet code=test2.class width=320 height=90>
< param name="but2" value="leave1.gif">
< /applet> */
public class test2 extends Applet implements MouseListener
{
Image imageb2;
int mousex;
int mousey;
public void init()
{
Cursor c=new Cursor(Cursor.HAND_CURSOR);
String imgname2=getParameter("but2");
imageb2=getImage(getDocumentBase(),imgname2);
addMouseListener(this);
}
public void mouseReleased(MouseEvent me){}
public void mouseClicked(MouseEvent me){}
public void mouseEntered(MouseEvent me)
{
mousex=me.getX();
mousey=me.getY();
// System.out.println("X CORDINATE IS "+mousex+" Y CORDINATE IS "+mousey);
if((mousex>12)&(mousex<94)&(mousey>9)&(mousey<33))
{
System.out.println("Hello");
}
}
public void mouseExited(MouseEvent me){}
public void mousePressed(MouseEvent me)
{}
public void paint(Graphics g)
{
g.drawImage(imageb2,10,10,this);
}
}

[This message has been edited by Jim Yingst (edited June 16, 2000).]
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this:
 
I don't like that guy. The tiny ad agrees with me.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic