List of usage examples for javax.swing JToggleButton setVerticalTextPosition
@BeanProperty(visualUpdate = true, enumerationValues = { "SwingConstants.TOP", "SwingConstants.CENTER", "SwingConstants.BOTTOM" }, description = "The vertical position of the text relative to the icon.") public void setVerticalTextPosition(int textPosition)
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 ww w . ja va2 s . c o 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) {/*from w w w. j av a 2s . c o 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)); }