글쓴이 :윤경구 2000년 6월 02일 15:30:47
In Reply to: 마우스 포인터를 내가 원하는 모양으로 바꾸고 싶습니다.. posted by 박재완 on 2000년 6월 02일 15:16:42:
Toolkit.createCustomCursor(Image, Point, String) throws IndexOutOfBoundsException 이라는 메소드가 JDK 1.2부터 제공됩니다.
간단한 예제입니다.
import java.awt.*;
public class CustomCursorTest extends Frame {
public CustomCursorTest() {
setSize(100,100);
show();
Image image = this.createImage(30,30);
drawCursor(image.getGraphics());
Point point = new Point(0, 0);
String string = new String("myCursor");
Cursor cursor = this.getToolkit().createCustomCursor(image, point, string);
setCursor(cursor);
}
private void drawCursor(Graphics g){
g.setColor(new Color(0,255,0));
g.fillRect(0,0,30,30);
g.setColor(new Color(0,0,0));
g.drawLine(1,1,10,20);
g.drawLine(20,1,10,20);
}
public static void main(String[] args) {
new CustomCursorTest();
}
}