Cursorオブジェクトの生成

編集者:Terai Atsuhiro
作成日:2005-01-24
更新日:2021-06-03 (木) 11:50:37

概要

新しいカスタムカーソルオブジェクトを作成します。

サンプルコード

BufferedImage bi2 = new BufferedImage(32, 32, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2d2 = bi2.createGraphics();
g2d2.setPaint(Color.red);
g2d2.drawOval(8, 8, 16, 16);
g2d2.dispose();
lbl2.setCursor(getToolkit().createCustomCursor(bi2,new Point(16,16),"oval"));

解説

Toolkit#createCustomCursorでカーソルオブジェクトを作成します。上記のサンプルでは、32*32のバッファの中心に、直径16ptの円をかき、中心がカーソルのホットスポットとなるようなカーソルを作っています。

コメント