• 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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:
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic