Java Code Examples for javax.swing.SwingConstants#SOUTH

The following examples show how to use javax.swing.SwingConstants#SOUTH . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: pumpernickel   File: BoxContainerPanelUI.java    License: MIT License 6 votes vote down vote up
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();
}
 
Example 2
Source Project: netbeans   File: EditorPaneTesting.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
/**
 * Convert the orientation of the pane into compass points based on the pane
 * orientation and the left-right orientation of the containter.
 *
 * @param  isLeft {@code true} if the component's container is laid out
 *                left-to-right, otherwise {@code false}.
 *
 * @return the compass direction for increasing the divider.
 */
private int mapDirection(boolean isLeft) {
    if (isLeft) {

        if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
            return SwingConstants.WEST;
        }

        return SwingConstants.NORTH;
    }

    if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        return SwingConstants.EAST;
    }

    return SwingConstants.SOUTH;
}
 
Example 4
public AxisComponent(ChartComponent chart, AxisMarksComputer marksComputer,
                     AxisMarksPainter marksPainter, int location, int mesh) {

    this.location = location;
    horizontal = location == SwingConstants.NORTH ||
                 location == SwingConstants.SOUTH;

    this.chart = chart;
    this.marksComputer = marksComputer;
    this.marksPainter = marksPainter;

    setOpaque(false);

    chart.addConfigurationListener(new ChartListener());

    if (mesh == MESH_BACKGROUND) chart.addPreDecorator(createMeshPainter());
    else if (mesh == MESH_FOREGROUND) chart.addPostDecorator(createMeshPainter());
}
 
Example 5
Source Project: pumpernickel   File: PlafPaintUtils.java    License: MIT License 5 votes vote down vote up
private static void drawColors(Color[] colors, Graphics g, int x1, int y1,
		int x2, int y2, int direction) {
	for (int a = 0; a < colors.length; a++) {
		g.setColor(colors[colors.length - a - 1]);
		if (direction == SwingConstants.SOUTH) {
			g.drawLine(x1, y1 - a, x2, y2 - a);
		} else if (direction == SwingConstants.NORTH) {
			g.drawLine(x1, y1 + a, x2, y2 + a);
		} else if (direction == SwingConstants.EAST) {
			g.drawLine(x1 - a, y1, x2 - a, y2);
		} else if (direction == SwingConstants.WEST) {
			g.drawLine(x1 + a, y1, x2 + a, y2);
		}
	}
}
 
Example 6
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;
}
 
Example 7
Source Project: FlatLaf   File: FlatComboBoxUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected JButton createArrowButton() {
	return new FlatArrowButton( SwingConstants.SOUTH, arrowType, buttonArrowColor,
		buttonDisabledArrowColor, buttonHoverArrowColor, null )
	{
		@Override
		protected boolean isHover() {
			return super.isHover() || (!comboBox.isEditable() ? hover : false);
		}
	};
}
 
Example 8
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
}
 
Example 9
Source Project: netbeans   File: CrossBorderLayout.java    License: Apache License 2.0 5 votes vote down vote up
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
}
 
Example 10
Source Project: SikuliX1   File: Resizable.java    License: MIT License 5 votes vote down vote up
private Rectangle getRectangle(int x, int y, int w, int h, int location) {

          switch (location) {

              case SwingConstants.NORTH:
                  return new Rectangle(x + w / 2 - dist / 2, y, dist, dist);

              case SwingConstants.SOUTH:
                  return new Rectangle(x + w / 2 - dist / 2, y + h - dist, dist, dist);

              case SwingConstants.WEST:
                  return new Rectangle(x, y + h / 2 - dist / 2, dist, dist);

              case SwingConstants.EAST:
                  return new Rectangle(x + w - dist, y + h / 2 - dist / 2, dist, dist);

              case SwingConstants.NORTH_WEST:
                  return new Rectangle(x, y, dist, dist);

              case SwingConstants.NORTH_EAST:
                  return new Rectangle(x + w - dist, y, dist, dist);

              case SwingConstants.SOUTH_WEST:
                  return new Rectangle(x, y + h - dist, dist, dist);

              case SwingConstants.SOUTH_EAST:
                  return new Rectangle(x + w - dist, y + h - dist, dist, dist);
          }
          return null;
      }
 
Example 11
@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);
}
 
Example 12
Source Project: netbeans   File: CrossBorderLayout.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 13
Source Project: RipplePower   File: LayoutStyle.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns the amount of space to use between two components. The return
 * value indicates the distance to place <code>component2</code> relative to
 * <code>component1</code>. For example, the following returns the amount of
 * space to place between <code>component2</code> and
 * <code>component1</code> when <code>component2</code> is placed vertically
 * above <code>component1</code>:
 * 
 * <pre>
 * int gap = getPreferredGap(component1, component2, LayoutStyle.RELATED, SwingConstants.NORTH, parent);
 * </pre>
 * 
 * The <code>type</code> parameter indicates the type of gap being
 * requested. It can be one of the following values:
 * <table>
 * <tr>
 * <td><code>RELATED</code>
 * <td>If the two components will be contained in the same parent and are
 * showing similar logically related items, use <code>RELATED</code>.
 * <tr>
 * <td><code>UNRELATED</code>
 * <td>If the two components will be contained in the same parent but show
 * logically unrelated items use <code>UNRELATED</code>.
 * <tr>
 * <td><code>INDENT</code>
 * <td>Used to obtain the preferred distance to indent a component relative
 * to another. For example, if you want to horizontally indent a JCheckBox
 * relative to a JLabel use <code>INDENT</code>. This is only useful for the
 * horizontal axis.
 * </table>
 * <p>
 * It's important to note that some look and feels may not distinguish
 * between <code>RELATED</code> and <code>UNRELATED</code>.
 * <p>
 * The return value is not intended to take into account the current size
 * and position of <code>component2</code> or <code>component1</code>. The
 * return value may take into consideration various properties of the
 * components. For example, the space may vary based on font size, or the
 * preferred size of the component.
 * 
 * @param component1
 *            the <code>JComponent</code> <code>component2</code> is being
 *            placed relative to
 * @param component2
 *            the <code>JComponent</code> being placed
 * @param type
 *            how the two components are being placed
 * @param position
 *            the position <code>component2</code> is being placed relative
 *            to <code>component1</code>; one of
 *            <code>SwingConstants.NORTH</code>,
 *            <code>SwingConstants.SOUTH</code>,
 *            <code>SwingConstants.EAST</code> or
 *            <code>SwingConstants.WEST</code>
 * @param parent
 *            the parent of <code>component2</code>; this may differ from
 *            the actual parent and may be null
 * @return the amount of space to place between the two components
 * @throws IllegalArgumentException
 *             if <code>position</code> is not one of
 *             <code>SwingConstants.NORTH</code>,
 *             <code>SwingConstants.SOUTH</code>,
 *             <code>SwingConstants.EAST</code> or
 *             <code>SwingConstants.WEST</code>; <code>type</code> not one
 *             of <code>INDENT</code>, <code>RELATED</code> or
 *             <code>UNRELATED</code>; or <code>component1</code> or
 *             <code>component2</code> is null
 */
public int getPreferredGap(JComponent component1, JComponent component2, int type, int position, Container parent) {
	if (position != SwingConstants.NORTH && position != SwingConstants.SOUTH && position != SwingConstants.WEST
			&& position != SwingConstants.EAST) {
		throw new IllegalArgumentException("Invalid position");
	}
	if (component1 == null || component2 == null) {
		throw new IllegalArgumentException("Components must be non-null");
	}
	if (type == RELATED) {
		return 6;
	} else if (type == UNRELATED) {
		return 12;
	} else if (type == INDENT) {
		if (position == SwingConstants.EAST || position == SwingConstants.WEST) {
			int gap = getButtonChildIndent(component1, position);
			if (gap != 0) {
				return gap;
			}
			return 6;
		}
		return 6;
	}
	throw new IllegalArgumentException("Invalid type");
}
 
Example 14
public DropDownArrowButton() {
	super(SwingConstants.SOUTH);
}
 
Example 15
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 16
Source Project: pumpernickel   File: BoxContainerPanelUI.java    License: MIT License 4 votes vote down vote up
public void defineShape(Rectangle r) {
	shape = new GeneralPath();
	int k1 = 15;
	int k2 = 8;
	switch (position) {
	case SwingConstants.NORTH_WEST:
		shape.moveTo(r.x, r.y);
		shape.lineTo(r.x + k1, r.y);
		shape.lineTo(r.x + k1, r.y - k2);
		shape.lineTo(r.x - k2, r.y - k2);
		shape.lineTo(r.x - k2, r.y + k1);
		shape.lineTo(r.x, r.y + k1);
		shape.closePath();
		break;
	case SwingConstants.NORTH_EAST:
		shape.moveTo(r.x + r.width, r.y);
		shape.lineTo(r.x + r.width - k1, r.y);
		shape.lineTo(r.x + r.width - k1, r.y - k2);
		shape.lineTo(r.x + r.width + k2, r.y - k2);
		shape.lineTo(r.x + r.width + k2, r.y + k1);
		shape.lineTo(r.x + r.width, r.y + k1);
		shape.closePath();
		break;
	case SwingConstants.SOUTH_WEST:
		shape.moveTo(r.x, r.y + r.height);
		shape.lineTo(r.x + k1, r.y + r.height);
		shape.lineTo(r.x + k1, r.y + r.height + k2);
		shape.lineTo(r.x - k2, r.y + r.height + k2);
		shape.lineTo(r.x - k2, r.y + r.height - k1);
		shape.lineTo(r.x, r.y + r.height - k1);
		shape.closePath();
		break;
	case SwingConstants.SOUTH_EAST:
		shape.moveTo(r.x + r.width, r.y + r.height);
		shape.lineTo(r.x + r.width - k1, r.y + r.height);
		shape.lineTo(r.x + r.width - k1, r.y + r.height + k2);
		shape.lineTo(r.x + r.width + k2, r.y + r.height + k2);
		shape.lineTo(r.x + r.width + k2, r.y + r.height - k1);
		shape.lineTo(r.x + r.width, r.y + r.height - k1);
		shape.closePath();
		break;
	case SwingConstants.NORTH:
		shape.moveTo(r.x + r.width / 2 - k1 / 2, r.y);
		shape.lineTo(r.x + r.width / 2 + k1 / 2, r.y);
		shape.lineTo(r.x + r.width / 2 + k1 / 2, r.y - k2);
		shape.lineTo(r.x + r.width / 2 - k1 / 2, r.y - k2);
		break;
	case SwingConstants.SOUTH:
		shape.moveTo(r.x + r.width / 2 - k1 / 2, r.y + r.height);
		shape.lineTo(r.x + r.width / 2 + k1 / 2, r.y + r.height);
		shape.lineTo(r.x + r.width / 2 + k1 / 2, r.y + r.height
				+ k2);
		shape.lineTo(r.x + r.width / 2 - k1 / 2, r.y + r.height
				+ k2);
		break;
	case SwingConstants.EAST:
		shape.moveTo(r.x, r.y + r.height / 2 - k1 / 2);
		shape.lineTo(r.x, r.y + r.height / 2 + k1 / 2);
		shape.lineTo(r.x - k2, r.y + r.height / 2 + k1 / 2);
		shape.lineTo(r.x - k2, r.y + r.height / 2 - k1 / 2);
		break;
	case SwingConstants.WEST:
		shape.moveTo(r.x + r.width, r.y + r.height / 2 - k1 / 2);
		shape.lineTo(r.x + r.width, r.y + r.height / 2 + k1 / 2);
		shape.lineTo(r.x + r.width + k2, r.y + r.height / 2 + k1
				/ 2);
		shape.lineTo(r.x + r.width + k2, r.y + r.height / 2 - k1
				/ 2);
		break;
	default:
		throw new RuntimeException("unexpected position: "
				+ position);
	}
}
 
Example 17
public DropDownArrowButton(DropDownButton attachedButton) {
	super(SwingConstants.SOUTH);
	this.attachedButton = attachedButton;
}
 
Example 18
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 19
Source Project: Java8CN   File: DefaultEditorKit.java    License: Apache License 2.0 4 votes vote down vote up
/** The operation to perform when this action is triggered. */
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target != null) {
        Caret caret = target.getCaret();
        DefaultCaret bidiCaret = (caret instanceof DefaultCaret) ?
                                      (DefaultCaret)caret : null;
        int dot = caret.getDot();
        Position.Bias[] bias = new Position.Bias[1];
        Point magicPosition = caret.getMagicCaretPosition();

        try {
            if(magicPosition == null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                Rectangle r = (bidiCaret != null) ?
                        target.getUI().modelToView(target, dot,
                                              bidiCaret.getDotBias()) :
                        target.modelToView(dot);
                magicPosition = new Point(r.x, r.y);
            }

            NavigationFilter filter = target.getNavigationFilter();

            if (filter != null) {
                dot = filter.getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            else {
                dot = target.getUI().getNextVisualPositionFrom
                             (target, dot, (bidiCaret != null) ?
                              bidiCaret.getDotBias() :
                              Position.Bias.Forward, direction, bias);
            }
            if(bias[0] == null) {
                bias[0] = Position.Bias.Forward;
            }
            if(bidiCaret != null) {
                if (select) {
                    bidiCaret.moveDot(dot, bias[0]);
                } else {
                    bidiCaret.setDot(dot, bias[0]);
                }
            }
            else {
                if (select) {
                    caret.moveDot(dot);
                } else {
                    caret.setDot(dot);
                }
            }
            if(magicPosition != null &&
               (direction == SwingConstants.NORTH ||
                direction == SwingConstants.SOUTH)) {
                target.getCaret().setMagicCaretPosition(magicPosition);
            }
        } catch (BadLocationException ex) {
        }
    }
}
 
Example 20
Source Project: netbeans   File: GlassPane.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Determines if we are moving south side of the component during resizing.
 *
 * @return {@code true} is we are moving south side of the component,
 * returns {@code false} otherwise.
 */
private boolean isResizingSouthward() {
    return (resizingMode == SwingConstants.SOUTH
            || resizingMode == SwingConstants.SOUTH_EAST
            || resizingMode == SwingConstants.SOUTH_WEST);
}