Example usage for javax.swing JToggleButton setHorizontalAlignment

List of usage examples for javax.swing JToggleButton setHorizontalAlignment

Introduction

In this page you can find the example usage for javax.swing JToggleButton setHorizontalAlignment.

Prototype

@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.LEFT", "SwingConstants.CENTER",
        "SwingConstants.RIGHT", "SwingConstants.LEADING",
        "SwingConstants.TRAILING" }, description = "The horizontal alignment of the icon and text.")
public void setHorizontalAlignment(int alignment) 

Source Link

Document

Sets the horizontal alignment of the icon and text.

Usage

From source file:components.CrayonPanel.java

protected JToggleButton createCrayon(String name, Border normalBorder) {
    JToggleButton crayon = new JToggleButton();
    crayon.setActionCommand(name);//from w  w w. ja  v a2 s . c  o m
    crayon.addActionListener(this);

    //Set the image or, if that's invalid, equivalent text.
    ImageIcon icon = createImageIcon("images/" + name + ".gif");
    if (icon != null) {
        crayon.setIcon(icon);
        crayon.setToolTipText("The " + name + " crayon");
        crayon.setBorder(normalBorder);
    } else {
        crayon.setText("Image not found. This is the " + name + " button.");
        crayon.setFont(crayon.getFont().deriveFont(Font.ITALIC));
        crayon.setHorizontalAlignment(JButton.HORIZONTAL);
        crayon.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    }

    return crayon;
}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

private static void setupToggleButton(JToggleButton button) {
    button.setBackground(m_but_color_bg);
    button.setFocusPainted(false);//from  w w  w .  j a  v  a2s.  co  m
    button.setBorder(new CompoundBorder(new LineBorder(m_but_color_bg), new EmptyBorder(0, 3, 0, 0)));
    button.setHorizontalAlignment(SwingConstants.LEFT);
}

From source file:op.controlling.PnlControlling.java

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

    if (tabMain.getSelectedIndex() == TAB_QMSPLAN) {

        final JToggleButton tbClosedOnes2 = GUITools
                .getNiceToggleButton(SYSTools.xx("misc.filters.showclosed"));

        ArrayList<Commontags> listTags = CommontagsTools.getAllUsedInQMSPlans(true);
        if (!listTags.isEmpty()) {

            JPanel pnlTags = new JPanel();
            pnlTags.setLayout(new BoxLayout(pnlTags, BoxLayout.PAGE_AXIS));
            pnlTags.setOpaque(false);/*from   w  w  w. ja v  a 2s.c o m*/

            final JButton btnReset = GUITools.createHyperlinkButton("misc.commands.resetFilter",
                    SYSConst.icon16tagPurpleDelete4, new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {

                            //                        init = true;
                            //                        tbClosedOnes2.setSelected(false);
                            //                        init = false;

                            //                        pnlQMSPlan.reload();
                            //
                            //                        pnlQMSPlan.cleanup();
                            //                        pnlQMSPlan = new PnlQMSPlan(null);
                            //                        tabMain.setComponentAt(TAB_QMSPLAN, pnlQMSPlan);

                            filterTag = null;
                            tbClosedOnes2.setSelected(false);

                        }
                    });
            pnlTags.add(btnReset, RiverLayout.LEFT);

            for (final Commontags commontag : listTags) {

                final JButton btnTag = GUITools.createHyperlinkButton(commontag.getText(),
                        SYSConst.icon16tagPurple, new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                //                            init = true;
                                //                            tbClosedOnes2.setSelected(true);
                                //                            init = false;
                                //
                                //                            pnlQMSPlan.cleanup();
                                //                            pnlQMSPlan = new PnlQMSPlan(null);
                                //                            tabMain.setComponentAt(TAB_QMSPLAN, pnlQMSPlan);
                                //                            //TODO: mark the filter when it is used. maybe a yellow background

                                filterTag = commontag;
                                tbClosedOnes2.setSelected(true);
                            }
                        });
                pnlTags.add(btnTag);

            }
            list.add(pnlTags);
        }

        tbClosedOnes2.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent itemEvent) {
                //                    if (init) return;
                pnlQMSPlan.reload(filterTag, itemEvent.getStateChange() == ItemEvent.SELECTED);
            }
        });
        list.add(tbClosedOnes2);
        tbClosedOnes2.setHorizontalAlignment(SwingConstants.LEFT);

    }

    return list;
}