Cursorオブジェクトの生成
Total: 10875, Today: 1, Yesterday: 2
Posted by aterai at
Last-modified:
Summary
BufferedImageからカーソルオブジェクトを作成し、これをコンポーネントに設定します。
Screenshot

Advertisement
Source Code Examples
BufferedImage bi = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = bi.createGraphics();
g2.setPaint(Color.RED);
g2.drawOval(8, 8, 16, 16);
g2.dispose();
button.setCursor(getToolkit().createCustomCursor(bi, new Point(16, 16), "oval"));
View in GitHub: Java, KotlinDescription
- サイズが
32x32pxのBufferedImageからToolkit#createCustomCursor(...)メソッドを使用してカーソルオブジェクトを作成- ホットスポットはその
BufferedImageの中心に設定
- ホットスポットはその
String:BufferedImageに文字を描画drawOval:BufferedImageに円を描画paintIcon:BufferedImageにIconを描画