Tuesday, August 31, 2010

Article | Java - Changing Mouse Icon Example

Java - Changing Mouse Icon Example

  1. import java.awt.*;
  2. import java.awt.event.*;
  3. public class ChangeCursor{
  4. public static void main(String[] args) {
  5. Frame m = new Frame("Change cursor");
  6. Panel panel = new Panel();
  7. Button b1 = new Button("Yes");
  8. Button b2 = new Button("No");
  9. panel.add(b1);
  10. panel.add(b2);
  11. m.add(panel,BorderLayout.CENTER);
  12. m.setSize(300,300);
  13. m.setVisible(true);
  14. Cursor c1 = b1.getCursor();
  15. Cursor c2 = b2.getCursor();
  16. b1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  17. b2.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
  18. m.addWindowListener(new WindowAdapter(){
  19. public void windowClosing(WindowEvent we){
  20. System.exit(0);
  21. }
  22. });
  23. }
  24. }
Loading...

Comments :

0 comments to “ Java - Changing Mouse Icon Example ”

Subscribe

Enter your email address:

Followers

Chicklets

My Zimbio