getPredefinedCursor ( )源码实例Demo

java.awt.Cursor#getPredefinedCursor ( )源码实例Demo

下面列出了java.awt.Cursor#getPredefinedCursor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: Utilities.java
public static Cursor createCustomCursor(Component component, Image icon, String name) {
    Toolkit t = component.getToolkit();
    Dimension d = t.getBestCursorSize(16, 16);
    Image i = icon;

    if (d.width != icon.getWidth(null)) {
        if (((d.width) == 0) && (d.height == 0)) {
            // system doesn't support custom cursors, falling back
            return Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
        }

        // need to resize the icon
        Image empty = ImageUtilities.createBufferedImage(d.width, d.height);
        i = ImageUtilities.mergeImages(icon, empty, 0, 0);
    }

    return t.createCustomCursor(i, new Point(1, 1), name);
}
 
源代码2 项目: pumpernickel   文件: BoxContainerPanelUI.java
public Cursor getCursor() {
	switch (position) {
	case SwingConstants.NORTH:
		return Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
	case SwingConstants.SOUTH:
		return Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
	case SwingConstants.EAST:
		return Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
	case SwingConstants.WEST:
		return Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
	case SwingConstants.NORTH_EAST:
		return Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
	case SwingConstants.SOUTH_EAST:
		return Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
	case SwingConstants.NORTH_WEST:
		return Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
	case SwingConstants.SOUTH_WEST:
		return Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
	}
	return Cursor.getDefaultCursor();
}
 
源代码3 项目: cncgcodecontroller   文件: Geometrics.java
/**
 * Returns the proper Cursor for the given area! 
 * @param area
 * @return 
 */
public static Cursor getCursor(EArea area){
    switch(area){
        case CENTER:                      
          return Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
        case RIGHT_SIDE:                      
          return Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
        case LEFT_SIDE:                      
          return Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
        case UPPER_SIDE:                      
          return Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
        case LOWER_SIDE:                      
          return Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
        case LL_CORNER:                      
          return Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
        case LR_CORNER:                      
          return Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
        case UL_CORNER:                      
          return Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
        case UR_CORNER:                      
          return Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
        default:
          return Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    }
}
 
源代码4 项目: osp   文件: GUIUtils.java
/**
 * Creates a custom cursor from an image. If an exception occurs, a predefined cursor is returned.
 *
 * @param image the Image
 * @param hotspot the position of the cursor hotspot
 * @param name the name of the cursor
 * @param predefinedCursorType one of the predefined Cursor types
 */
public static Cursor createCustomCursor(Image image, Point hotspot, String name, int predefinedCursorType) {
 try {
	return Toolkit.getDefaultToolkit().createCustomCursor(image, hotspot, name);
} catch (Exception ex) {
  try {
		return Cursor.getPredefinedCursor(predefinedCursorType);
	} catch (Exception ex1) {
	}
}
 return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
}
 
源代码5 项目: snap-desktop   文件: InsertPlacemarkInteractor.java
private Cursor createCursor() {
    final Image cursorImage = placemarkDescriptor.getCursorImage();
    if (cursorImage == null) {
        return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
    }
    return Toolkit.getDefaultToolkit().createCustomCursor(cursorImage,
                                                          placemarkDescriptor.getCursorHotSpot(),
                                                          placemarkDescriptor.getRoleName());
}
 
源代码6 项目: visualvm   文件: FlashingIcon.java
@Override
public Cursor getCursor() {

    if( isIconVisible ) {
        return Cursor.getPredefinedCursor( Cursor.HAND_CURSOR );
    }
    return Cursor.getDefaultCursor();
}
 
源代码7 项目: netbeans   文件: FlashingIcon.java
@Override
public Cursor getCursor() {

    if( isIconVisible ) {
        return Cursor.getPredefinedCursor( Cursor.HAND_CURSOR );
    }
    return Cursor.getDefaultCursor();
}
 
源代码8 项目: visualvm   文件: TimelinePanel.java
private void updateCursor() {
    if (draggingRow != null) {
        Cursor resizeCursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
        chart.setCursor(resizeCursor);
        probesPanel.setCursor(resizeCursor);
    } else {
        Cursor defaultCursor = Cursor.getDefaultCursor();
        chart.setCursor(defaultCursor);
        probesPanel.setCursor(defaultCursor);
    }
}
 
源代码9 项目: dsworkbench   文件: ImageManager.java
public static Cursor createVillageDragCursor(int pVillageCount) {
    try {
        Image i = ImageIO.read(new File("graphics/cursors/village_drag.png"));
        i.getGraphics().setColor(Color.BLACK);
        i.getGraphics().drawString(Integer.toString(pVillageCount), 5, 12);
        return Toolkit.getDefaultToolkit().createCustomCursor(i, new Point(0, 0), "Village");
    } catch (Exception ignored) {
    }
    return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
}
 
源代码10 项目: netbeans   文件: HyperlinkOperation.java
private static synchronized Cursor getMouseCursor(HyperlinkType type) {
    switch (type) {
        case GO_TO_DECLARATION:
        case ALT_HYPERLINK:
            return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
        default:
            throw new UnsupportedOperationException();
    }
}
 
private void init() {
    normal = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    crop = getCropCursor();
    start = new Point(0, 0);
    end = new Point(0, 0);
    click = new Point(0, 0);
    offsetMark = new Point(0, 0);
    offset = new Point(0, 0);
    setLayout(null);
    this.setIgnoreRepaint(true);
    editor = new CropPanel(this);
    add(editor);
}
 
public VisualGraphTranslatingGraphMousePlugin(int modifiers) {
	super(modifiers);
	this.cursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
}
 
源代码13 项目: Logisim   文件: TextTool.java
@Override
public Cursor getCursor(Canvas canvas) {
	return Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR);
}
 
public VisualGraphZoomingPickingGraphMousePlugin() {
	super(InputEvent.BUTTON1_MASK);
	this.cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
}
 
源代码15 项目: FancyBing   文件: GoGui.java
private void setCursor(Component component, int type)
{
    Cursor cursor = Cursor.getPredefinedCursor(type);
    component.setCursor(cursor);
}
 
源代码16 项目: netbeans   文件: DragManager.java
public Cursor getCursor() {
    return Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
}
 
源代码17 项目: Logisim   文件: RectangularTool.java
@Override
public Cursor getCursor(Canvas canvas) {
	return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
}
 
源代码18 项目: Logisim   文件: SelectTool.java
@Override
public Cursor getCursor(Canvas canvas) {
	return Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
}
 
源代码19 项目: netbeans   文件: FlashingIcon.java
@Override
public Cursor getCursor() {
    return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
}
 
源代码20 项目: netbeans   文件: HyperlinkOperation.java
private static synchronized boolean isHyperlinkMouseCursor(Cursor c) {
    return    c == Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
           || c == Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)
           || c == Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
}