Example usage for javax.swing JToggleButton setFont

List of usage examples for javax.swing JToggleButton setFont

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.")
public void setFont(Font font) 

Source Link

Document

Sets the font for this component.

Usage

From source file:components.CrayonPanel.java

protected JToggleButton createCrayon(String name, Border normalBorder) {
    JToggleButton crayon = new JToggleButton();
    crayon.setActionCommand(name);//from www . j  a  v  a 2 s.  com
    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:io.gameover.utilities.pixeleditor.Pixelizer.java

private void addSelectFrameButtonToPanel(int index) {
    JToggleButton button = new JToggleButton("" + index);
    button.setPreferredSize(new Dimension(20, 20));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setFont(button.getFont().deriveFont(9f));
    button.setActionCommand("" + (index - 1));
    button.addActionListener(getSelectFrameActionListener());
    button.addMouseListener(new SelectFramePopClickListener(this, index - 1));
    this.selectFrameButtons.add(button);
    this.selectFramePanel.add(button,
            LayoutUtils.xyi((index - 1) % 4 + 1, (index - 1) / 4 + 1, 0d, 0d, new Insets(1, 1, 1, 1)));
}

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.//  w  w w  .  jav  a 2s. 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) {//  w ww .  java 2 s . c om
    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));
}

From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private JToggleButton createViewToggleButton(final String text, final String iconPath) {
    final ImageIcon icon = imageManager.getImageIcon(iconPath);
    final JToggleButton button = new JToggleButton(text, icon);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFont(WidgetUtils.FONT_SMALL);
    button.setForeground(WidgetUtils.BG_COLOR_BRIGHTEST);
    button.setBackground(WidgetUtils.BG_COLOR_DARK);
    button.setBorderPainted(false);/*from   ww w  . ja  va  2s  .  com*/
    button.setBorder(new CompoundBorder(WidgetUtils.BORDER_THIN, new EmptyBorder(0, 4, 0, 4)));
    return button;
}