Tuesday, March 17, 2009
Changing Mouse Icon Example
import java.awt.*;
import java.awt.event.*;
public class ChangeCursor{
public static void main(String[] args) {
Frame m = new Frame("Change cursor");
Panel panel = new Panel();
Button b1 = new Button("Yes");
Button b2 = new Button("No");
panel.add(b1);
panel.add(b2);
m.add(panel,BorderLayout.CENTER);
m.setSize(300,300);
m.setVisible(true);
Cursor c1 = b1.getCursor();
Cursor c2 = b2.getCursor();
b1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
b2.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
m.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment