자바 2 (JDK 1.2 이후 버전)부터 기능이 제공됩니다.


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]

글쓴이 :윤경구 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();
}
}




다음 글들:



이어서 글올리기(답하기)

이름:
E-Mail:
제목:
내용:
HTML 태그 포함 여부: HTML 문서일 경우 체크
관련 URL(선택):
URL 제목(선택):
관련 이미지 URL:


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]