Example usage for javax.swing JToggleButton getFont

List of usage examples for javax.swing JToggleButton getFont

Introduction

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

Prototype

@Transient
public Font getFont() 

Source Link

Document

Gets the font of this component.

Usage

From source file:components.CrayonPanel.java

protected JToggleButton createCrayon(String name, Border normalBorder) {
    JToggleButton crayon = new JToggleButton();
    crayon.setActionCommand(name);/*from   w ww . j  ava 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./*from  ww  w .  j  a v  a2s.c  om*/
 * 
 * @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;
}