Substance API

View all API methods.

View all client properties.


API method

public static void setFontSizeExtra(int value)

Description

Sets the new extra font size.

Parameters:

  • value - New value for extra font size.

See also


Sample code

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.jvnet.substance.SubstanceLookAndFeel;

/**
 * Test application that shows the use of the
 {@link SubstanceLookAndFeel#setFontSizeExtra(int)} APIs.
 
 @author Kirill Grouchnikov
 @see SubstanceLookAndFeel#setFontSizeExtra(int)
 */
public class SetFontSizeExtra extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public SetFontSizeExtra() {
    super("Set font size extra");

    this.setLayout(new BorderLayout());

    JPanel panel = new JPanel(new FlowLayout());

    // create a slider to control the font size extra.
    final JSlider fontSizeExtraSlider = new JSlider(-440);
    fontSizeExtraSlider.setPaintLabels(true);
    fontSizeExtraSlider.setPaintTicks(true);
    fontSizeExtraSlider.setMajorTickSpacing(2);
    fontSizeExtraSlider.setMinorTickSpacing(1);
    fontSizeExtraSlider.setSnapToTicks(true);

    fontSizeExtraSlider.addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent e) {
        // if the value is adjusting - ignore. This is done
        // to make CPU usage better.
        if (fontSizeExtraSlider.getValueIsAdjusting())
          return;
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            // Set the font size extra
            SubstanceLookAndFeel
                .setFontSizeExtra(fontSizeExtraSlider
                    .getValue());
            // reset the LAF to have the changes
            try {
              UIManager
                  .setLookAndFeel(new SubstanceLookAndFeel());
            catch (Exception exc) {
            }
            SwingUtilities
                .updateComponentTreeUI(SetFontSizeExtra.this);
          }
        });
      }
    });
    panel.add(fontSizeExtraSlider);

    this.add(panel, BorderLayout.CENTER);

    this.setSize(400200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }

  /**
   * The main method for <code>this</code> sample. The arguments are
   * ignored.
   
   @param args
   *            Ignored.
   @throws Exception
   *             If some exception occured. Note that there is no special
   *             treatment of exception conditions in <code>this</code>
   *             sample code.
   */
  public static void main(String[] argsthrows Exception {
    UIManager.setLookAndFeel(new SubstanceLookAndFeel());
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new SetFontSizeExtra().setVisible(true);
      }
    });
  }
}

The screenshot below shows application frame under default extra font size (0) - this method has not been called:

The screenshot below shows application frame after this method has been called with value 3 (note how it affects all UI elements):

The screenshot below shows application frame after this method has been called with value -2 (note how it affects all UI elements):