Example usage for javax.swing SwingConstants NORTH

List of usage examples for javax.swing SwingConstants NORTH

Introduction

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

Prototype

int NORTH

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

Click Source Link

Document

Compass-direction North (up).

Usage

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

From source file:Main.java

public static Point arrangeWithin(final Shape shapeToArrange, final Rectangle window, final int arrangement,
        Insets padding) {//from w  w w  .  j a  va2  s  .co  m
    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 w w  w.j  a  va  2  s .  com
        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).//w  ww. j  a va2 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   www .j  a v a2s  . 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);
        }/*from w  ww .j  a  v a 2  s .  co m*/
    }
}

From source file:SortedTableModel.java

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Component text;/*from w w w.j a  v a 2s .c  o  m*/
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    if (textRenderer != null) {
        text = textRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    } else {
        text = new JLabel((String) value, JLabel.CENTER);
        LookAndFeel.installColorsAndFont((JComponent) text, "TableHeader.background", "TableHeader.foreground",
                "TableHeader.font");
    }
    panel.add(text, BorderLayout.CENTER);

    if (column == sortColumn) {
        BasicArrowButton bab = new BasicArrowButton(
                (sortAscending ? SwingConstants.NORTH : SwingConstants.SOUTH));
        panel.add(bab, BorderLayout.WEST);
    }
    LookAndFeel.installBorder(panel, "TableHeader.cellBorder");
    return panel;
}

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   ww  w.  j  a v  a 2s. c om
        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.allowance.PnlAllowance.java

private JPanel createContentPanel4(final Resident resident) {
    JPanel pnlContent = new JPanel(new VerticalLayout());

    final JidePopup popupTX = new JidePopup();
    popupTX.setMovable(false);/*from   www  . ja  va2s. c  o  m*/

    PnlTX pnlTX = getPnlTX(resident, null);

    popupTX.setContentPane(pnlTX);
    popupTX.removeExcludedComponent(pnlTX);
    popupTX.setDefaultFocusComponent(pnlTX);

    final JideButton btnNewTX = GUITools.createHyperlinkButton(SYSTools.xx("admin.residents.cash.enterTXs"),
            SYSConst.icon22add, null);
    btnNewTX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            popupTX.setOwner(btnNewTX);
            GUITools.showPopup(popupTX, SwingConstants.NORTH);
        }
    });
    btnNewTX.setBackground(getBG(resident, 9));
    btnNewTX.setOpaque(true);
    pnlContent.add(btnNewTX);

    if (!minmax.containsKey(resident)) {
        minmax.put(resident, AllowanceTools.getMinMax(resident));
    }

    if (minmax.get(resident) != null) {

        LocalDate start = SYSCalendar.bom(minmax.get(resident).getFirst());
        LocalDate end = resident.isActive() ? new LocalDate()
                : SYSCalendar.eom(minmax.get(resident).getSecond());

        CollapsiblePane cpArchive = new CollapsiblePane(SYSTools.xx("admin.residents.cash.archive"));
        try {
            cpArchive.setCollapsed(true);
        } catch (PropertyVetoException e) {
            //bah!
        }
        cpArchive.setBackground(getBG(resident, 7));
        JPanel pnlArchive = new JPanel(new VerticalLayout());
        cpArchive.setContentPane(pnlArchive);
        for (int year = end.getYear(); year >= start.getYear(); year--) {
            if (year >= new LocalDate().getYear() - 1) {
                pnlContent.add(createCP4(resident, year));
            } else if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.ARCHIVE, internalClassID)) {
                pnlArchive.add(createCP4(resident, year));
            }
        }
        if (pnlArchive.getComponentCount() > 0) {
            pnlContent.add(cpArchive);
        }
    }
    return pnlContent;
}

From source file:op.care.dfn.PnlDFN.java

private java.util.List<Component> addCommands() {

    java.util.List<Component> list = new ArrayList<Component>();

    /***//  w ww.  j  a v  a  2  s  .  c  o  m
     *      _     _            _       _     _
     *     | |__ | |_ _ __    / \   __| | __| |
     *     | '_ \| __| '_ \  / _ \ / _` |/ _` |
     *     | |_) | |_| | | |/ ___ \ (_| | (_| |
     *     |_.__/ \__|_| |_/_/   \_\__,_|\__,_|
     *
     */
    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) {

        final JideButton btnAdd = GUITools.createHyperlinkButton(SYSTools.xx("nursingrecords.dfn.btnadd"),
                SYSConst.icon22add, null);
        btnAdd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if (!resident.isActive()) {
                    OPDE.getDisplayManager()
                            .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident"));
                    return;
                }

                final JidePopup popup = new JidePopup();
                popup.setMovable(false);
                PnlSelectIntervention pnl = new PnlSelectIntervention(new Closure() {
                    @Override
                    public void execute(Object o) {
                        popup.hidePopup();
                        if (o != null) {
                            Object[] objects = (Object[]) o;
                            EntityManager em = OPDE.createEM();
                            try {
                                em.getTransaction().begin();
                                em.lock(em.merge(resident), LockModeType.OPTIMISTIC);

                                for (Object obj : objects) {
                                    Intervention intervention = em.merge((Intervention) obj);
                                    DFN dfn = em.merge(new DFN(resident, intervention));

                                    // Set Target and Actual according to the setting of JDCDate
                                    DateTime now = new DateTime();
                                    DateMidnight onDemandPIT = new DateMidnight(jdcDate.getDate());
                                    DateTime newDateTime = onDemandPIT.toDateTime()
                                            .plusHours(now.getHourOfDay()).plusMinutes(now.getMinuteOfHour())
                                            .plusSeconds(now.getSecondOfMinute());
                                    dfn.setSoll(newDateTime.toDate());
                                    dfn.setIst(newDateTime.toDate());

                                    CollapsiblePane cp1 = createCP4(dfn);
                                    synchronized (mapDFN2Pane) {
                                        mapDFN2Pane.put(dfn, cp1);
                                    }
                                    synchronized (mapShift2DFN) {
                                        mapShift2DFN.get(dfn.getShift()).add(dfn);
                                    }
                                }

                                em.getTransaction().commit();

                                CollapsiblePane cp2 = createCP4(DFNTools.SHIFT_ON_DEMAND);
                                synchronized (mapShift2Pane) {
                                    mapShift2Pane.put(DFNTools.SHIFT_ON_DEMAND, cp2);
                                }
                                buildPanel(false);
                                try {
                                    synchronized (mapShift2Pane) {
                                        mapShift2Pane.get(DFNTools.SHIFT_ON_DEMAND).setCollapsed(false);
                                    }
                                } catch (PropertyVetoException e) {
                                    OPDE.debug(e);
                                }

                            } catch (OptimisticLockException ole) {
                                OPDE.warn(ole);
                                if (em.getTransaction().isActive()) {
                                    em.getTransaction().rollback();
                                }
                                if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                    OPDE.getMainframe().emptyFrame();
                                    OPDE.getMainframe().afterLogin();
                                }
                                OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                            } catch (Exception e) {
                                if (em.getTransaction().isActive()) {
                                    em.getTransaction().rollback();
                                }
                                OPDE.fatal(e);
                            } finally {
                                em.close();
                            }
                        }
                    }
                });
                popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
                popup.getContentPane().add(pnl);
                popup.setOwner(btnAdd);
                popup.removeExcludedComponent(pnl);
                popup.setDefaultFocusComponent(pnl);
                GUITools.showPopup(popup, SwingConstants.NORTH);
            }
        });
        list.add(btnAdd);

    }

    final JideButton printPrescription = GUITools.createHyperlinkButton("nursingrecords.dfn.print",
            SYSConst.icon22print2, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {

                    String html = "";

                    synchronized (mapShift2DFN) {
                        html += "<h1 id=\"fonth1\" >" + ResidentTools.getFullName(resident) + "</h1>";
                        html += SYSConst.html_h2(SYSTools.xx("nursingrecords.bhp") + ": "
                                + SYSConst.html_bold(DateFormat.getDateInstance().format(jdcDate.getDate())));

                        for (Byte shift : new Byte[] { DFNTools.SHIFT_ON_DEMAND, DFNTools.SHIFT_VERY_EARLY,
                                DFNTools.SHIFT_EARLY, DFNTools.SHIFT_LATE, DFNTools.SHIFT_VERY_LATE }) {
                            html += DFNTools.getDFNsAsHTMLtable(mapShift2DFN.get(shift));
                        }
                    }

                    SYSFilesTools.print(html, true);
                }
            });
    list.add(printPrescription);
    return list;
}