Example usage for javax.swing JToggleButton setHorizontalTextPosition

List of usage examples for javax.swing JToggleButton setHorizontalTextPosition

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.LEFT", "SwingConstants.CENTER",
        "SwingConstants.RIGHT", "SwingConstants.LEADING",
        "SwingConstants.TRAILING" }, description = "The horizontal position of the text relative to the icon.")
public void setHorizontalTextPosition(int textPosition) 

Source Link

Document

Sets the horizontal position of the text relative to the icon.

Usage

From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java

/**
 * Subroutine of {@link #buildUI()}. Makes a chart type toggle button and
 * adds it to the button group.//from   w w  w  .  j  ava 2  s  . co  m
 * 
 * @param caption
 *            The text to appear under the button
 * @param type
 *            The type of chart the buttons should select
 * @param icon
 *            The icon for the button
 * @param fontSize
 *            the font size for the toggle buttons. The default font size of
 *            the toggle buttons are different than the default font size of
 *            JButtons on some platforms. This value should be equal to the
 *            JButton font size. This is a float as deriving fonts with a size
 *            takes a float.
 * @return A button properly configured for the new-look Wabit toolbar.
 */
private JToggleButton makeChartTypeButton(String caption, ChartType type, Icon icon, float fontSize) {
    JToggleButton b = new JToggleButton(caption, icon);
    b.putClientProperty(CHART_TYPE_PROP_KEY, type);
    chartTypeButtonGroup.add(b);

    b.setVerticalTextPosition(SwingConstants.BOTTOM);
    b.setHorizontalTextPosition(SwingConstants.CENTER);

    // Removes button borders on OS X 10.5
    b.putClientProperty("JButton.buttonType", "toolbar");

    b.addActionListener(genericActionListener);

    b.setFont(b.getFont().deriveFont(fontSize));

    return b;
}

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

private static void setupButton(JToggleButton button, String toolTipText, String rolloverImg,
        String selectedImg) {//  ww w.  jav  a  2s.co m
    button.setFont(new Font("Dialog", Font.PLAIN, 12));
    button.setVerticalTextPosition(SwingConstants.BOTTOM);
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    button.setText(toolTipText);
    button.setRolloverIcon(new ImageIcon(Constants.IMG_FOLDER + rolloverImg));
    button.setSelectedIcon(new ImageIcon(Constants.IMG_FOLDER + selectedImg));
    button.setBackground(m_selected_but_color);
    button.setToolTipText(toolTipText);

    // Remove border
    Border emptyBorder = BorderFactory.createEmptyBorder();
    button.setBorder(emptyBorder);
    // Set adequate size
    button.setPreferredSize(new Dimension(32, 32));
}