Example usage for javax.swing SwingConstants EAST

List of usage examples for javax.swing SwingConstants EAST

Introduction

In this page you can find the example usage for javax.swing SwingConstants EAST.

Prototype

int EAST

To view the source code for javax.swing SwingConstants EAST.

Click Source Link

Document

Compass-direction east (right).

Usage

From source file:Main.java

public static void main(final String args[]) {
    ArrowButton button = new ArrowButton(SwingConstants.EAST, 1, 30);

    JOptionPane.showMessageDialog(null, button);

    button.doClick();//from ww w .j av a2  s  .  c  o m
}

From source file:Main.java

public static void validateDirection(int direction) {
    if (direction != SwingConstants.NORTH && direction != SwingConstants.EAST
            && direction != SwingConstants.SOUTH && direction != SwingConstants.WEST) {
        throw new IllegalArgumentException("invalid direction");
    }//ww  w .  j  a  v a 2 s  .c o m
}

From source file:Main.java

public static Point arrangeWithin(final Shape shapeToArrange, final Rectangle window, final int arrangement,
        Insets padding) {/*w  w  w  .ja  v a 2 s  .com*/
    if (shapeToArrange == null)
        throw new IllegalArgumentException("Parameter 'shapeToArrange' must not be null!");
    if (window == null)
        throw new IllegalArgumentException("Parameter 'window' must not be null!");
    if (padding == null)
        padding = new Insets(0, 0, 0, 0);

    final Rectangle bounds = shapeToArrange.getBounds();

    switch (arrangement) {
    case SwingConstants.NORTH:
        return new Point((window.width - bounds.width) / 2, padding.top);
    case SwingConstants.NORTH_EAST:
        return new Point(window.width - padding.right, padding.top);
    case SwingConstants.EAST:
        return new Point(window.width - padding.right, (window.height - bounds.height) / 2);
    case SwingConstants.SOUTH_EAST:
        return new Point(window.width - padding.right, window.height - padding.bottom);
    case SwingConstants.SOUTH:
        return new Point((window.width - bounds.width) / 2, window.height - padding.bottom);
    case SwingConstants.SOUTH_WEST:
        return new Point(padding.left, window.height - padding.bottom);
    case SwingConstants.WEST:
        return new Point(padding.left, (window.height - bounds.height) / 2);
    case SwingConstants.NORTH_WEST:
        return new Point(padding.left, padding.top);
    case SwingConstants.CENTER:
        return new Point((window.width - bounds.width) / 2, (window.height - bounds.height) / 2);
    default:
        throw new IllegalArgumentException("Illegal arrangement key, expected one of the SwingConstants keys");
    }
}

From source file:Main.java

protected void createComponents() {
    if (orientation == SwingConstants.VERTICAL) {
        setLayout(new GridLayout(2, 1));
        incrementButton = new BasicArrowButton(SwingConstants.NORTH);
        decrementButton = new BasicArrowButton(SwingConstants.SOUTH);
        add(incrementButton);//from   ww w  . j  a v  a 2s  .  c  o  m
        add(decrementButton);
    } else if (orientation == SwingConstants.HORIZONTAL) {
        setLayout(new GridLayout(1, 2));
        incrementButton = new BasicArrowButton(SwingConstants.EAST);
        decrementButton = new BasicArrowButton(SwingConstants.WEST);
        add(decrementButton);
        add(incrementButton);
    }
}

From source file:PaintUtils.java

/** Uses translucent shades of white and black to draw highlights
 * and shadows around a rectangle, and then frames the rectangle
 * with a shade of gray (120)./*from  w  ww.ja  va 2  s  . c o m*/
 * <P>This should be called to add a finishing touch on top of
 * existing graphics.
 * @param g the graphics to paint to.
 * @param r the rectangle to paint.
 */
public static void drawBevel(Graphics g, Rectangle r) {
    drawColors(blacks, g, r.x, r.y + r.height, r.x + r.width, r.y + r.height, SwingConstants.SOUTH);
    drawColors(blacks, g, r.x + r.width, r.y, r.x + r.width, r.y + r.height, SwingConstants.EAST);

    drawColors(whites, g, r.x, r.y, r.x + r.width, r.y, SwingConstants.NORTH);
    drawColors(whites, g, r.x, r.y, r.x, r.y + r.height, SwingConstants.WEST);

    g.setColor(new Color(120, 120, 120));
    g.drawRect(r.x, r.y, r.width, r.height);
}

From source file:Main.java

public Dimension getMinimumSize() {
    return new Dimension(
            arrowSize * (direction == SwingConstants.EAST || direction == SwingConstants.WEST ? arrowCount : 3)
                    + getBorder().getBorderInsets(this).left + getBorder().getBorderInsets(this).right,
            arrowSize/*from  w w  w .  j av  a2  s.c  om*/
                    * (direction == SwingConstants.NORTH || direction == SwingConstants.SOUTH ? arrowCount : 3)
                    + getBorder().getBorderInsets(this).top + getBorder().getBorderInsets(this).bottom);
}

From source file:PaintUtils.java

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);
        }/* w w w . j a v  a  2  s . co  m*/
    }
}

From source file:Main.java

protected void paintComponent(Graphics g) {
    // this will paint the background
    super.paintComponent(g);

    Color oldColor = g.getColor();
    g.setColor(isEnabled() ? getForeground() : getForeground().brighter());

    // paint the arrows
    int w = getSize().width;
    int h = getSize().height;
    for (int i = 0; i < arrowCount; i++) {
        paintArrow(g, (w - arrowSize//from w w w .j a va 2  s  .  c  om
                * (direction == SwingConstants.EAST || direction == SwingConstants.WEST ? arrowCount : 1)) / 2
                + arrowSize * (direction == SwingConstants.EAST || direction == SwingConstants.WEST ? i : 0),
                (h - arrowSize * (direction == SwingConstants.EAST || direction == SwingConstants.WEST ? 1
                        : arrowCount)) / 2
                        + arrowSize * (direction == SwingConstants.EAST || direction == SwingConstants.WEST ? 0
                                : i),
                g.getColor());
    }

    g.setColor(oldColor);
}

From source file:DateTimeEditor.java

protected void createComponents() {
    if (m_orientation == SwingConstants.VERTICAL) {
        setLayout(new GridLayout(2, 1));
        m_incrementButton = new BasicArrowButton(SwingConstants.NORTH);
        m_decrementButton = new BasicArrowButton(SwingConstants.SOUTH);
        add(m_incrementButton);//from   www  .j a va 2s .  com
        add(m_decrementButton);
    } else if (m_orientation == SwingConstants.HORIZONTAL) {
        setLayout(new GridLayout(1, 2));
        m_incrementButton = new BasicArrowButton(SwingConstants.EAST);
        m_decrementButton = new BasicArrowButton(SwingConstants.WEST);
        add(m_decrementButton);
        add(m_incrementButton);
    }
}

From source file:op.care.info.DlgDiag.java

private void btnAddGPActionPerformed(ActionEvent e) {
    final PnlEditGP pnlGP = new PnlEditGP(new GP());
    JidePopup popup = GUITools.createPanelPopup(pnlGP, new Closure() {
        @Override/*from w  ww  .  j  a va  2s.  co  m*/
        public void execute(Object o) {
            if (o != null) {
                GP gp = EntityTools.merge((GP) o);
                cmbArzt.setModel(new DefaultComboBoxModel(new GP[] { gp }));
            }
        }
    }, btnAddGP);
    GUITools.showPopup(popup, SwingConstants.EAST);
}