當前位置: 首頁>>代碼示例>>Java>>正文


Java Cursor.getDefaultCursor方法代碼示例

本文整理匯總了Java中java.awt.Cursor.getDefaultCursor方法的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.getDefaultCursor方法的具體用法?Java Cursor.getDefaultCursor怎麽用?Java Cursor.getDefaultCursor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Cursor的用法示例。


在下文中一共展示了Cursor.getDefaultCursor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCursor

import java.awt.Cursor; //導入方法依賴的package包/類
public static Cursor getCursor( int which ) {
	Cursor c = (Cursor) cursorCache.get(new Integer(which));
	if (c != null) return c;

	try {
		ClassLoader loader = org.geomapapp.util.Icons.class.getClassLoader();
		String path = "org/geomapapp/resources/icons/" +names[which];
		java.net.URL url = loader.getResource(path);
		BufferedImage im = ImageIO.read(url);
		String name = names[which].substring(0, names[which].lastIndexOf("."));
		System.out.println(im.getWidth() + "\t" + im.getHeight());
		
		c = Toolkit.getDefaultToolkit().createCustomCursor(im, new Point(hotSpot[which][0],hotSpot[which][1]), name);
		cursorCache.put(new Integer(which), c);
		return c;
	} catch(Exception ex) {
		return Cursor.getDefaultCursor();
	}
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:20,代碼來源:Cursors.java

示例2: updateCursor

import java.awt.Cursor; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:TimelinePanel.java

示例3: getCursor

import java.awt.Cursor; //導入方法依賴的package包/類
@Override
public Cursor getCursor() {

    if( isIconVisible ) {
        return Cursor.getPredefinedCursor( Cursor.HAND_CURSOR );
    }
    return Cursor.getDefaultCursor();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:FlashingIcon.java

示例4: updateCursor

import java.awt.Cursor; //導入方法依賴的package包/類
/**
 * Updates cursor according to its location. For example, it sets
 * the appropriate resizing cursor when the mouse is over the boundary
 * of the selection component.
 *
 * @param cursorLocation current mouse cursor location.
 */
void updateCursor(Point cursorLocation) {
    Cursor cursor = Cursor.getDefaultCursor();
    if (cursorLocation == null) {
        resizingMode = 0;
    } else {
        int x = cursorLocation.x;
        int y = cursorLocation.y;
        Image resizeHandle = GridDesigner.RESIZE_HANDLE;
        int rw = resizeHandle.getWidth(null);
        int rh = resizeHandle.getHeight(null);
        for (Component selComp : selection) {
            Rectangle rect = fromComponentPane(selectionResizingBounds(selComp));
            boolean w = (rect.x-rw<=x) && (x<=rect.x+rect.width+rw);
            boolean h = (rect.y-rh<=y) && (y<=rect.y+rect.height+rh);
            boolean top = w && (rect.y-rh<=y) && (y<=rect.y+2);
            boolean bottom = w && (rect.y+rect.height-2<=y) && (y<=rect.y+rect.height+rh);
            boolean left = h && (rect.x-rw<=x) && (x<=rect.x+2);
            boolean right = h && (rect.x+rect.width-2<=x) && (x<=rect.x+rect.width+rw);
            if (top) {
                if (left) {
                    cursor = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
                    resizingMode = SwingConstants.NORTH_WEST;
                } else if (right) {
                    cursor = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
                    resizingMode = SwingConstants.NORTH_EAST;
                } else {
                    cursor = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
                    resizingMode = SwingConstants.NORTH;
                }
            } else if (bottom) {
                if (left) {
                    cursor = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
                    resizingMode = SwingConstants.SOUTH_WEST;
                } else if (right) {
                    cursor = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
                    resizingMode = SwingConstants.SOUTH_EAST;
                } else {
                    cursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
                    resizingMode = SwingConstants.SOUTH;
                }
            } else if (left) {
                cursor = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
                resizingMode = SwingConstants.WEST;
            } else if (right) {
                cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
                resizingMode = SwingConstants.EAST;
            } else {
                cursor = Cursor.getDefaultCursor();
                resizingMode = 0;
            }
            if (resizingMode != 0) {
                focusedComponent = selComp;
                break;
            }
        }
    }
    setCursor(cursor);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:66,代碼來源:GlassPane.java


注:本文中的java.awt.Cursor.getDefaultCursor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。