-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangeCursor.java
More file actions
executable file
·45 lines (31 loc) · 883 Bytes
/
ChangeCursor.java
File metadata and controls
executable file
·45 lines (31 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.awt.*;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ChangeCursor
{
JFrame frame;
JPanel myPanel;
Image image;
public ChangeCursor ()
{
frame = new JFrame ("Change Cursor Demo");
myPanel = new JPanel ();
myPanel.setPreferredSize(new Dimension(400, 500));
myPanel.setBackground (new Color (150, 150, 200));
// Loading the image into an Image object
image = Toolkit.getDefaultToolkit().getImage("pencil.gif");
// Defining the hotspot to the centre of the object
Point hotspot = new Point (0, 0);
Toolkit toolkit = Toolkit.getDefaultToolkit ();
Cursor cursor = toolkit.createCustomCursor (image, hotspot, "pen");
frame.setCursor (cursor);
frame.add(myPanel);
frame.pack();
frame.setVisible(true);
}
public static void main (String [] args)
{
new ChangeCursor ();
}
}