Showing posts with label change cursor in java awt. Show all posts
Showing posts with label change cursor in java awt. Show all posts

Friday, 28 June 2013

Changing the Cursor in Java awt


/**
 * @(#)Text3.java
 *
 *
 * @author
 * @version 1.00 2013/6/28
 */
import java.awt.*;
import java.awt.event.*;
class Cursorch extends Frame implements ActionListener
{
    Button btn_1,btn_2;
    public Cursorch()
    {
        setLayout(new FlowLayout());
        setTitle("Cursor");
        setSize(500,500);
        setLocation(100,100);
       
        btn_1=new Button("Get Cursor 1");
        btn_1.addActionListener(this);
        add(btn_1);
       
        btn_2=new Button("Get Cursor 1");
        btn_2.addActionListener(this);
        add(btn_2);
       
        Cursor cur = btn_1.getCursor();
          Cursor cur1 = btn_2.getCursor();
          btn_1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
          btn_2.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
         
          addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
           
    }
    public void actionPerformed(ActionEvent ae)
    {
    }
}
class ChangeCursor
{
    public static void main(String []args)
    {
        new Cursorch().setVisible(true);
    }
}