Saturday, April 24, 2010

Change cursor for a component  

0 comments

  1. import java.awt.Frame;
  2. import java.awt.Component;
  3. import java.awt.Cursor;
  4. import java.awt.event.WindowListener;
  5. import java.awt.event.WindowAdapter;
  6. import java.awt.event.WindowEvent;
  7. public class HowToChangeComponentCursor
  8. {
  9. public static void main(String[]args)
  10. {
  11. WindowListener wl=new WindowAdapter()
  12. {
  13. public void windowClosing(WindowEvent evt)
  14. {
  15. System.exit(0);
  16. }
  17. };
  18. Frame a=new Frame("HOVER YOUR CURSOR IN THIS FRAME");
  19. a.addWindowListener(wl);
  20. //METHOD setCursor WILL SET NEW CURSOR FOR COMPONENT
  21. a.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
  22. a.setSize(800,600);
  23. a.setVisible(true);
  24. }
  25. }


JUST COMPILE AND EXECUTE IT

What next?

You can also bookmark this post using your favorite bookmarking service:

Related Posts by Categories



Extension Factory Builder