Example usage for javax.swing UIManager getFont

List of usage examples for javax.swing UIManager getFont

Introduction

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

Prototype

public static Font getFont(Object key) 

Source Link

Document

Returns a font from the defaults.

Usage

From source file:com.moneydance.modules.features.importlist.util.Preferences.java

public static Font getHeaderFont() {
    final Font baseFont = UIManager.getFont("Label.font");
    return baseFont.deriveFont(Font.PLAIN, baseFont.getSize2D() + 2.0F);
}

From source file:com.moneydance.modules.features.importlist.util.Preferences.java

private static Font getBodyFont() {
    return UIManager.getFont("Label.font");
}

From source file:net.sf.jhylafax.JHylaFAX.java

public static void initializeToolkit() {
    // configure UI properties
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    UIManager.put("SplitPaneDivider.border", new BasicBorders.MarginBorder());
    UIManager.put("TitledBorder.font", UIManager.getFont("Label.font").deriveFont(Font.BOLD));
    UIManager.put("TitledBorder.titleColor", UIManager.getColor("Label.foreground").brighter());

    Builder.setProperty(DefaultFactory.ENHANCED_TEXT_FIELD_MENU_KEY, true);
}

From source file:au.org.ala.delta.intkey.ui.CharacterImageDialog.java

private void init(List<Character> characters, Character dependentCharacter, boolean valuesEditable) {
    ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(CharacterImageDialog.class);
    resourceMap.injectFields(this);

    _characters = characters;/*from   w  ww  .jav a 2s. com*/
    _valuesEditable = valuesEditable;
    getContentPane().setLayout(new BorderLayout(0, 0));

    buildMenuItems();

    if (dependentCharacter != null) {
        if (characters.size() != 1) {
            throw new IllegalArgumentException(
                    "Dependent character should only be supplied if there is a single character being viewed in the dialog");
        }

        Character ch = characters.get(0);

        _pnlControllingCharacterMessage = new JPanel();
        _pnlControllingCharacterMessage.setFocusable(false);
        _pnlControllingCharacterMessage.setBorder(new EmptyBorder(5, 0, 0, 0));
        getContentPane().add(_pnlControllingCharacterMessage, BorderLayout.NORTH);
        _pnlControllingCharacterMessage.setLayout(new BorderLayout(0, 0));

        _lblWarningIcon = new JLabel("");
        _lblWarningIcon.setFocusable(false);
        _lblWarningIcon.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
        _pnlControllingCharacterMessage.add(_lblWarningIcon, BorderLayout.WEST);

        _txtControllingCharacterMessage = new JTextArea();
        CharacterFormatter formatter = new CharacterFormatter(true, CommentStrippingMode.RETAIN,
                AngleBracketHandlingMode.REMOVE_SURROUNDING_REPLACE_INNER, true, false);
        String setControllingCharacterMessage = UIUtils.getResourceString(
                "MultiStateInputDialog.setControllingCharacterMessage",
                formatter.formatCharacterDescription(dependentCharacter),
                formatter.formatCharacterDescription(ch));
        _txtControllingCharacterMessage.setText(setControllingCharacterMessage);
        _txtControllingCharacterMessage.setFocusable(false);
        _txtControllingCharacterMessage.setBorder(new EmptyBorder(0, 5, 0, 0));
        _txtControllingCharacterMessage.setEditable(false);
        _pnlControllingCharacterMessage.add(_txtControllingCharacterMessage);
        _txtControllingCharacterMessage.setWrapStyleWord(true);
        _txtControllingCharacterMessage.setFont(UIManager.getFont("Button.font"));
        _txtControllingCharacterMessage.setLineWrap(true);
        _txtControllingCharacterMessage.setBackground(SystemColor.control);
    }
}

From source file:LocationSensitiveDemo.java

private static void increaseFont(String type) {
    Font font = UIManager.getFont(type);
    font = font.deriveFont(font.getSize() + 4f);
    UIManager.put(type, font);// www  . j  av  a 2 s . c  o  m
}

From source file:gate.Main.java

/**
 * Reads the user config data and applies the required settings.
 * This must be called <b>after</b> {@link Gate#init()} but <b>before</b>
 * any GUI components are created./*from   w  w  w .j  a v a2s.c  o m*/
 */
public static void applyUserPreferences() {
    //look and feel
    String lnfClassName;
    if (System.getProperty("swing.defaultlaf") != null) {
        lnfClassName = System.getProperty("swing.defaultlaf");
    } else {
        lnfClassName = Gate.getUserConfig().getString(GateConstants.LOOK_AND_FEEL);
    }
    if (lnfClassName == null) {
        //if running on Linux, default to Metal rather than GTK because GTK LnF
        //doesn't play nicely with most Gnome themes
        if (System.getProperty("os.name").toLowerCase().indexOf("linux") != -1) {
            //running on Linux
            lnfClassName = UIManager.getCrossPlatformLookAndFeelClassName();
        } else {
            lnfClassName = UIManager.getSystemLookAndFeelClassName();
        }
    }
    try {
        UIManager.setLookAndFeel(lnfClassName);
    } catch (Exception e) {
        System.err.print("Could not set your preferred Look and Feel. The error was:\n" + e.toString()
                + "\nReverting to using Java Look and Feel");
        try {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (Exception e1) {
            //we just can't catch a break here. Let's forget about look and feel.
            System.err.print("Could not set the cross-platform Look and Feel either. The error was:\n"
                    + e1.toString() + "\nGiving up on Look and Feel.");
        }
    }
    Gate.getUserConfig().put(GateConstants.LOOK_AND_FEEL, lnfClassName);

    //read the user config data
    OptionsMap userConfig = Gate.getUserConfig();

    //text font
    Font font = userConfig.getFont(GateConstants.TEXT_COMPONENTS_FONT);
    if (font == null) {
        font = UIManager.getFont("TextPane.font");
    }

    if (font != null) {
        OptionsDialog.setTextComponentsFont(font);
    }

    //menus font
    font = userConfig.getFont(GateConstants.MENUS_FONT);
    if (font == null) {
        font = UIManager.getFont("Menu.font");
    }

    if (font != null) {
        OptionsDialog.setMenuComponentsFont(font);
    }

    //other gui font
    font = userConfig.getFont(GateConstants.OTHER_COMPONENTS_FONT);
    if (font == null) {
        font = UIManager.getFont("Button.font");
    }

    if (font != null) {
        OptionsDialog.setComponentsFont(font);
    }

}

From source file:uk.ac.lkl.cram.ui.chart.HoursChartMaker.java

/**
 * Create a chart from the provided category dataset
 * @return a Chart that can be rendered in a ChartPanel
 *//*from  w  w  w . jav  a  2 s  . c  om*/
@Override
protected JFreeChart createChart() {
    //Create a vertical stacked bar chart from the chart factory, with no title, no axis labels, a legend, tooltips but no URLs
    JFreeChart chart = ChartFactory.createStackedBarChart(null, null, null, (CategoryDataset) dataset,
            PlotOrientation.VERTICAL, true, true, false);
    //Get the font from the platform UI
    Font chartFont = UIManager.getFont("Label.font");
    //Get the plot from the chart
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    //Get the renderer from the plot
    StackedBarRenderer sbRenderer = (StackedBarRenderer) plot.getRenderer();
    //Set the rendered to use a standard bar painter (nothing fancy)
    sbRenderer.setBarPainter(new StandardBarPainter());
    //Set the colours for the bars
    sbRenderer.setSeriesPaint(0, PREPARATION_COLOR);
    sbRenderer.setSeriesPaint(1, SUPPORT_COLOR);
    //Set the tooltip to be series, category and value
    sbRenderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator("{0}, {1} ({2})", NumberFormat.getInstance()));
    //Get the category axis (that's the X-axis in this case)
    CategoryAxis categoryAxis = plot.getDomainAxis();
    //Set the font for rendering the labels on the x-axis to be the platform default
    categoryAxis.setLabelFont(chartFont);
    //Get the number axis (that's the Y-axis in this case)
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    //Use the same font as the x-axis
    numberAxis.setLabelFont(chartFont);
    return chart;
}

From source file:com.limegroup.gnutella.gui.LicenseWindow.java

/**
 * Builds a new JTextArea with the appropriate values set.
 */// w w w.  j  ava 2 s . c o m
private JTextArea newTextArea(String msg) {
    JTextArea text = new JTextArea();
    text.setLineWrap(true);
    text.setWrapStyleWord(true);
    text.setEditable(false);
    text.setFont(UIManager.getFont("Table.font"));
    JLabel label = new JLabel();
    text.setForeground(label.getForeground());
    text.setBackground(label.getBackground());
    text.setText(msg);
    return text;
}

From source file:com.sshtools.common.ui.SshToolsApplication.java

/**
 *
 *
 * @param className/*from   w w  w  .j ava2  s.  c  om*/
        
        
 *
 * @throws Exception
 */
public static void setLookAndFeel(String className) throws Exception {
    LookAndFeel laf = null;

    if (!className.equals(DEFAULT_LAF)) {
        if (className.equals(SYSTEM_LAF)) {
            String systemLaf = UIManager.getSystemLookAndFeelClassName();
            log.debug("System Look And Feel is " + systemLaf);
            laf = (LookAndFeel) Class.forName(systemLaf).newInstance();
        } else if (className.equals(CROSS_PLATFORM_LAF)) {
            String crossPlatformLaf = UIManager.getCrossPlatformLookAndFeelClassName();
            log.debug("Cross Platform Look And Feel is " + crossPlatformLaf);
            laf = (LookAndFeel) Class.forName(crossPlatformLaf).newInstance();
        } else {
            laf = (LookAndFeel) Class.forName(className).newInstance();
        }
    }

    //  Now actually set the look and feel
    if (laf != null) {
        log.info("Setting look and feel " + laf.getName() + " (" + laf.getClass().getName() + ")");
        UIManager.setLookAndFeel(laf);
        UIManager.put("EditorPane.font", UIManager.getFont("TextArea.font"));
    }
}

From source file:au.org.ala.delta.editor.DeltaEditor.java

@Action
public void chooseFont() {
    Font f = UIManager.getFont("Label.font");
    Font newFont = JFontChooser.showDialog(_desktop, "Please select a font", f);
    if (newFont != null) {
        updateFont(newFont);//from   www. j  a  v  a2  s.co  m
        SwingUtilities.updateComponentTreeUI(getMainFrame());
        EditorPreferences.setPreferredFont(newFont);
    }
}