本文整理汇总了Java中javax.swing.SwingConstants.EAST属性的典型用法代码示例。如果您正苦于以下问题:Java SwingConstants.EAST属性的具体用法?Java SwingConstants.EAST怎么用?Java SwingConstants.EAST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.SwingConstants
的用法示例。
在下文中一共展示了SwingConstants.EAST属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDecreaseButton
protected JButton createDecreaseButton(int orientation) {
JButton btn = new XDMButton();
btn.setHorizontalAlignment(JButton.CENTER);
btn.setPreferredSize(new Dimension(15, 15));
btn.setContentAreaFilled(false);
btn.setBorderPainted(false);
btn.setOpaque(false);
if (orientation == SwingConstants.NORTH) {
btn.setIcon(XDMIconMap.getIcon("UP_ARROW"));
}
if (orientation == SwingConstants.SOUTH) {
btn.setIcon(XDMIconMap.getIcon("DOWN_ARROW"));
}
if (orientation == SwingConstants.EAST) {
btn.setIcon(XDMIconMap.getIcon("LEFT_ARROW"));
}
if (orientation == SwingConstants.WEST) {
btn.setIcon(XDMIconMap.getIcon("RIGHT_ARROW"));
}
return btn;
}
示例2: run
@Override
protected void run(Context context) throws Exception {
Random random = context.container().random();
int actionIndex = random.nextInt(4);
boolean select = random.nextBoolean();
int direction;
switch (actionIndex) {
case 0:
direction = SwingConstants.WEST;
break;
case 1:
direction = SwingConstants.EAST;
break;
case 2:
direction = SwingConstants.NORTH;
break;
case 3:
direction = SwingConstants.SOUTH;
break;
default:
throw new IllegalStateException("Invalid actionIndex=" + actionIndex); // NOI18N
}
moveOrSelect(context, direction, select);
}
示例3: createIncreaseButton
protected JButton createIncreaseButton(int orientation) {
JButton btn = new XDMButton();
btn.setHorizontalAlignment(JButton.CENTER);
btn.setPreferredSize(new Dimension(15, 15));
btn.setContentAreaFilled(false);
btn.setBorderPainted(false);
if (orientation == SwingConstants.NORTH) {
btn.setIcon(XDMIconMap.getIcon("UP_ARROW"));
}
if (orientation == SwingConstants.SOUTH) {
btn.setIcon(XDMIconMap.getIcon("DOWN_ARROW"));
}
if (orientation == SwingConstants.EAST) {
btn.setIcon(XDMIconMap.getIcon("LEFT_ARROW"));
}
if (orientation == SwingConstants.WEST) {
btn.setIcon(XDMIconMap.getIcon("RIGHT_ARROW"));
}
return btn;
}
示例4: getLayoutComponent
public Component getLayoutComponent(int constraint) {
if (constraint == SwingConstants.NORTH) return north;
if (constraint == SwingConstants.WEST) return west;
if (constraint == SwingConstants.SOUTH) return south;
if (constraint == SwingConstants.EAST) return east;
if (constraint == SwingConstants.CENTER) return center;
throw new IllegalArgumentException("Illegal constraint: " + // NOI18N
constraintName(constraint));
}
示例5: isBasis
private static boolean isBasis(int constraint) {
if (constraint == SwingConstants.NORTH) return true;
if (constraint == SwingConstants.WEST) return true;
if (constraint == SwingConstants.SOUTH) return true;
if (constraint == SwingConstants.EAST) return true;
if (constraint == SwingConstants.CENTER) return true;
return false;
}
示例6: checkSupported
private static void checkSupported(int constraint) {
if (constraint == SwingConstants.NORTH) return;
if (constraint == SwingConstants.WEST) return;
if (constraint == SwingConstants.SOUTH) return;
if (constraint == SwingConstants.EAST) return;
if (constraint == SwingConstants.NORTH_WEST) return;
if (constraint == SwingConstants.NORTH_EAST) return;
if (constraint == SwingConstants.SOUTH_WEST) return;
if (constraint == SwingConstants.SOUTH_EAST) return;
if (constraint == SwingConstants.CENTER) return;
throw new IllegalArgumentException("Unsupported constraint: " + constraint); // NOI18N
}
示例7: constraintName
private static String constraintName(int constraint) {
if (constraint == SwingConstants.NORTH) return "NORTH"; // NOI18N
if (constraint == SwingConstants.WEST) return "WEST"; // NOI18N
if (constraint == SwingConstants.SOUTH) return "SOUTH"; // NOI18N
if (constraint == SwingConstants.EAST) return "EAST"; // NOI18N
if (constraint == SwingConstants.NORTH_WEST) return "NORTH_WEST"; // NOI18N
if (constraint == SwingConstants.NORTH_EAST) return "NORTH_EAST"; // NOI18N
if (constraint == SwingConstants.SOUTH_WEST) return "SOUTH_WEST"; // NOI18N
if (constraint == SwingConstants.SOUTH_EAST) return "SOUTH_EAST"; // NOI18N
if (constraint == SwingConstants.CENTER) return "CENTER"; // NOI18N
return "UNSUPPORTED_CONSTRAINT (value=" + constraint + ")"; // NOI18N
}
示例8: displayPopup
protected void displayPopup() {
JPopupMenu menu = new JPopupMenu();
populatePopup(menu);
if (menu.getComponentCount() > 0) {
Dimension size = menu.getPreferredSize();
size.width = Math.max(size.width, getWidth());
menu.setPreferredSize(size);
int align = getPopupAlign();
int x;
switch (align) {
case SwingConstants.EAST:
case SwingConstants.NORTH_EAST:
case SwingConstants.SOUTH_EAST:
x = getWidth() - size.width;
break;
default:
x = 0;
break;
}
int y;
switch (align) {
case SwingConstants.NORTH:
case SwingConstants.NORTH_EAST:
case SwingConstants.NORTH_WEST:
y = -size.height;
break;
default:
y = getHeight();
break;
}
menu.show(this, x, y);
}
}
示例9: paintComponent
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
GeneralPath arrow = new GeneralPath();
int w, h;
switch (direction) {
case SwingConstants.SOUTH:
h = 2;
w = 4;
arrow.moveTo(getWidth() / 2 - w, getHeight() / 2);
arrow.lineTo(getWidth() / 2 + w, getHeight() / 2);
arrow.lineTo(getWidth() / 2, getHeight() / 2 + 2 * h);
arrow.closePath();
break;
case SwingConstants.EAST:
h = 4;
w = 2;
arrow.moveTo(getWidth() / 2 - w, getHeight() / 2 - h);
arrow.lineTo(getWidth() / 2 + w, getHeight() / 2);
arrow.lineTo(getWidth() / 2 - w, getHeight() / 2 + h);
arrow.closePath();
break;
default:
throw new IllegalArgumentException("Illegal direction: " + direction);
}
if (isEnabled()) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
((Graphics2D) g).fill(arrow);
}
示例10: getButtonAdjustment
private int getButtonAdjustment(JComponent source, int edge) {
String uid = source.getUIClassID();
if (uid == "ButtonUI" || uid == "ToggleButtonUI") {
if (!isOcean && (edge == SwingConstants.EAST ||
edge == SwingConstants.SOUTH)) {
return 1;
}
}
else if (edge == SwingConstants.SOUTH) {
if (uid == "RadioButtonUI" || (!isOcean && uid == "CheckBoxUI")) {
return 1;
}
}
return 0;
}
示例11: getPadding
private int getPadding(int axis) {
int position;
if (axis == HORIZONTAL) {
position = SwingConstants.EAST;
} else {
position = SwingConstants.SOUTH;
}
return getLayoutStyle0().getPreferredGap(source,
target, type, position, host);
}
示例12: isRightAligned
private boolean isRightAligned(AbstractButton button, int position) {
if (position == SwingConstants.EAST) {
boolean ltr = button.getComponentOrientation().isLeftToRight();
int hAlign = button.getHorizontalAlignment();
return ((ltr && (hAlign == SwingConstants.RIGHT ||
hAlign == SwingConstants.TRAILING)) ||
(!ltr && (hAlign == SwingConstants.LEADING)));
}
return false;
}
示例13: updateCursor
/**
* 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);
}
示例14: isEast
private static boolean isEast(Integer[] constraints) {
return constraints[1] == SwingConstants.EAST;
}
示例15: show
public void show() {
// Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
// if (focusOwner != null) focusRef = new WeakReference(focusOwner);
owner = ownerRef == null ? null : ownerRef.get();
ownerLocation = owner == null ? null : owner.getLocationOnScreen();
window = new JWindow(owner);
window.setType(Window.Type.POPUP);
window.setAlwaysOnTop(false);
window.setFocusable(true);
window.setFocusableWindowState(true);
window.setAutoRequestFocus(true);
window.getContentPane().add(content);
window.pack();
if (popupAlign == -1) {
window.setLocation(location.getLocation());
} else {
Dimension size = content.getSize();
int x;
switch (popupAlign) {
case SwingConstants.EAST:
case SwingConstants.NORTH_EAST:
case SwingConstants.SOUTH_EAST:
x = location.x + location.width - size.width + 1;
break;
default:
x = location.x + 1;
break;
}
int y;
switch (popupAlign) {
case SwingConstants.NORTH:
case SwingConstants.NORTH_EAST:
case SwingConstants.NORTH_WEST:
y = location.y - size.height + 1;
break;
default:
y = location.y + location.height + 1;
break;
}
window.setLocation(x, y);
}
window.setVisible(true);
Component defaultFocus = content.getFocusTraversalPolicy().getDefaultComponent(content);
if (defaultFocus != null) defaultFocus.requestFocusInWindow();
content.installListeners();
if (listener != null) listener.popupShown();
}