本文整理匯總了Java中java.awt.Cursor.DEFAULT_CURSOR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Cursor.DEFAULT_CURSOR屬性的具體用法?Java Cursor.DEFAULT_CURSOR怎麽用?Java Cursor.DEFAULT_CURSOR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.awt.Cursor
的用法示例。
在下文中一共展示了Cursor.DEFAULT_CURSOR屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mouseDragged
public void mouseDragged(MouseEvent e) {
check(e);
Window w = SwingUtilities.getWindowAncestor((Component)e.getSource());
if (Cursor.DEFAULT_CURSOR == cursorType) {
// resize only when mouse pointer in resize areas
return;
}
Rectangle newBounds = computeNewBounds(w, getScreenLoc(e));
if (!w.getBounds().equals(newBounds)) {
w.setBounds(newBounds);
}
}
示例2: mouseMoved
@Override
public void mouseMoved(MouseEvent evt) {
if (mouseState == MouseState.DEFAULT) {
boolean textCursor = true;
int position = component.viewToModel(evt.getPoint());
if (RectangularSelectionUtils.isRectangularSelection(component)) {
List<Position> positions = RectangularSelectionUtils.regionsCopy(component);
for (int i = 0; textCursor && i < positions.size(); i += 2) {
int a = positions.get(i).getOffset();
int b = positions.get(i + 1).getOffset();
if (a == b) {
continue;
}
textCursor &= !(position >= a && position <= b || position >= b && position <= a);
}
} else {
// stream selection
if (getDot() == getMark()) {
// empty selection
textCursor = true;
} else {
int dot = getDot();
int mark = getMark();
if (position >= dot && position <= mark || position >= mark && position <= dot) {
textCursor = false;
} else {
textCursor = true;
}
}
}
if (textCursor != showingTextCursor) {
int cursorType = textCursor ? Cursor.TEXT_CURSOR : Cursor.DEFAULT_CURSOR;
component.setCursor(Cursor.getPredefinedCursor(cursorType));
showingTextCursor = textCursor;
}
}
}
示例3: mouseMoved
@Override
public void mouseMoved(MouseEvent evt) {
if (mouseState == MouseState.DEFAULT) {
boolean textCursor = true;
int position = component.viewToModel(evt.getPoint());
if (RectangularSelectionUtils.isRectangularSelection(component)) {
List<Position> positions = RectangularSelectionUtils.regionsCopy(component);
for (int i = 0; textCursor && i < positions.size(); i += 2) {
int a = positions.get(i).getOffset();
int b = positions.get(i + 1).getOffset();
if (a == b) {
continue;
}
textCursor &= !(position >= a && position <= b || position >= b && position <= a);
}
} else // stream selection
if (getDot() == getMark()) {
// empty selection
textCursor = true;
} else {
int dot = getDot();
int mark = getMark();
if (position >= dot && position <= mark || position >= mark && position <= dot) {
textCursor = false;
} else {
textCursor = true;
}
}
if (textCursor != showingTextCursor) {
int cursorType = textCursor ? Cursor.TEXT_CURSOR : Cursor.DEFAULT_CURSOR;
component.setCursor(Cursor.getPredefinedCursor(cursorType));
showingTextCursor = textCursor;
}
}
}
示例4: setWaitCursor
void setWaitCursor(boolean yes) {
if (yes) {
Cursor hourglassCursor = new Cursor(Cursor.WAIT_CURSOR);
setCursor(hourglassCursor);
} else {
Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);
setCursor(normalCursor);
}
}
示例5: getCursorType
private int getCursorType (Rectangle b, Point p) {
int leftDist = p.x - b.x;
int rightDist = (b.x + b.width) - p.x;
int topDist = p.y - b.y;
int bottomDist = (b.y + b.height) - p.y;
boolean isNearTop = topDist >= 0 && topDist <= insets.top;
boolean isNearBottom = bottomDist >= 0 && bottomDist <= insets.bottom;
boolean isNearLeft = leftDist >= 0 && leftDist <= insets.left;
boolean isNearRight = rightDist >= 0 && rightDist <= insets.right;
boolean isInTopPart = topDist >= 0 && topDist <= insets.top + 10;
boolean isInBottomPart = bottomDist >= 0 && bottomDist <= insets.bottom + 10;
boolean isInLeftPart = leftDist >= 0 && leftDist <= insets.left + 10;
boolean isInRightPart = rightDist >= 0 && rightDist <= insets.right + 10;
if (isNearTop && isInLeftPart || isInTopPart && isNearLeft) {
return Cursor.NW_RESIZE_CURSOR;
}
if (isNearTop && isInRightPart || isInTopPart && isNearRight) {
return Cursor.NE_RESIZE_CURSOR;
}
if (isNearBottom && isInLeftPart || isInBottomPart && isNearLeft) {
return Cursor.SW_RESIZE_CURSOR;
}
if (isNearBottom && isInRightPart || isInBottomPart && isNearRight) {
return Cursor.SE_RESIZE_CURSOR;
}
if (isNearTop) {
return Cursor.N_RESIZE_CURSOR;
}
if (isNearLeft) {
return Cursor.W_RESIZE_CURSOR;
}
if (isNearRight) {
return Cursor.E_RESIZE_CURSOR;
}
if (isNearBottom) {
return Cursor.S_RESIZE_CURSOR;
}
return Cursor.DEFAULT_CURSOR;
}
示例6: mouseMoved
public void mouseMoved(Point point) {
synchronized (mouseLock) {
if (mousePressedPosition != null)
mouseDragPosition = point;
Bounds bounds = getSelected(point);
int cursorType;
if (bounds == null)
cursorType = Cursor.DEFAULT_CURSOR;
else {
cursorType = Cursor.MOVE_CURSOR;
}
if (selection.getBounds().length == 1) {
boolean resizableX = selection.isResizeableX(diagram);
boolean resizableY = selection.isResizeableY(diagram);
if ((resizableX) && (isRightMove(point)))
cursorType = Cursor.E_RESIZE_CURSOR;
else if ((resizableX) && (isLeftMove(point)))
cursorType = Cursor.W_RESIZE_CURSOR;
else if ((resizableY) && (isTopMove(point)))
cursorType = Cursor.N_RESIZE_CURSOR;
else if ((resizableY) && (isBottomMove(point)))
cursorType = Cursor.S_RESIZE_CURSOR;
else if ((resizableY) && (resizableX)
&& (isRightBottomMove(point)))
cursorType = Cursor.SE_RESIZE_CURSOR;
else if ((resizableY) && (resizableX)
&& (isLeftBottomMove(point)))
cursorType = Cursor.SW_RESIZE_CURSOR;
else if ((resizableY) && (resizableX)
&& (isTopRightMove(point)))
cursorType = Cursor.NE_RESIZE_CURSOR;
else if ((resizableY) && (resizableX) && (isTopLeftMove(point)))
cursorType = Cursor.NW_RESIZE_CURSOR;
}
if (this.cursorType != cursorType) {
this.cursorType = cursorType;
this.setCursor(new Cursor(cursorType));
}
}
repaint();
}