Here you can find the source of createCursor(URL url, Point hotSpot, String name)
public static Cursor createCursor(URL url, Point hotSpot, String name)
//package com.java2s; /*/*from www . j ava 2 s.c om*/ * Copyright (C) 2006 The Concord Consortium, Inc., * 25 Love Lane, Concord, MA 01742 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * END LICENSE */ import java.awt.Cursor; import java.awt.Dimension; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import java.net.URL; import javax.swing.ImageIcon; public class Main { public static Cursor createCursor(URL url, Point hotSpot, String name) { return createCursor(new ImageIcon(url), hotSpot, name); } public static Cursor createCursor(ImageIcon cursorIcon, Point hotSpot, String name) { return createCursor(cursorIcon.getImage(), hotSpot, name); } public static Cursor createCursor(Image cursorImage, Point hotSpot, String name) { if (hotSpot == null) hotSpot = new Point(); Dimension prefDimension = Toolkit.getDefaultToolkit().getBestCursorSize(hotSpot.x, hotSpot.y); if (hotSpot.x > prefDimension.width - 1) hotSpot.x = prefDimension.width - 1; else if (hotSpot.x < 0) hotSpot.x = 0; if (hotSpot.y > prefDimension.height - 1) hotSpot.y = prefDimension.height - 1; else if (hotSpot.y < 0) hotSpot.y = 0; return Toolkit.getDefaultToolkit().createCustomCursor(cursorImage, hotSpot, name); } }