Example usage for javax.swing UIManager get

List of usage examples for javax.swing UIManager get

Introduction

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

Prototype

public static Object get(Object key) 

Source Link

Document

Returns an object from the defaults.

Usage

From source file:au.org.ala.delta.intkey.Intkey.java

/**
 * Prompt the user to select the font to use in the application
 *///from w  w  w  .ja v  a  2s  . c  o m
@Action
public void chooseFont() {
    Font f = UIManager.getFont("Label.font");
    Font newFont = JFontChooser.showDialog(getMainFrame(),
            UIUtils.getResourceString("SelectFontPrompt.caption"), f);
    if (newFont != null) {
        FontUIResource fontResource = new FontUIResource(newFont);
        Enumeration<Object> keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof javax.swing.plaf.FontUIResource) {
                UIManager.put(key, fontResource);
            }
        }
        SwingUtilities.updateComponentTreeUI(getMainFrame());
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

public void initGlobalFontSetting(Font fnt) {
    FontUIResource fontRes = new FontUIResource(fnt);
    for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof FontUIResource) {
            UIManager.put(key, fontRes);
        }//www.ja va2s. c  o m
    }
    SwingUtilities.updateComponentTreeUI(this);
}

From source file:v800_trainer.JCicloTronic.java

public static void setFontSizeGlobal(String font, int size) {
    for (Enumeration e = UIManager.getDefaults().keys(); e.hasMoreElements();) {
        Object key = e.nextElement();
        Object value = UIManager.get(key);

        if (value instanceof Font) {
            Font f = (Font) value;

            UIManager.put(key, new javax.swing.plaf.FontUIResource(font, f.getStyle(), size));
        }/* w w w  .  jav  a 2 s . com*/
    }
}

From source file:net.team2xh.crt.gui.util.GUIToolkit.java

/**
 * Defines the default font for Swing./*from  ww  w  . j a v a 2  s.  c om*/
 *
 * All Swing elements instantiated after this method call will
 * use the provided font name and size.
 *
 * @param name Name of the font family
 * @param size Font size
 */
public static void setDefaultFont(String name, int size) {
    java.util.Enumeration<Object> keys = UIManager.getDefaults().keys();
    Font font = new Font(name, Font.PLAIN, size);
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        // Replace all instances of font resources
        if (value != null && value instanceof javax.swing.plaf.FontUIResource)
            UIManager.put(key, font);
    }
}

From source file:net.team2xh.crt.gui.util.GUIToolkit.java

/**
 * Activeate Substance Look&Feel./*from w ww  .j a v a2 s  . c  o m*/
 *
 * Must be called before opening any window.
 * 
 * @param laf Desired Substance Look&Feel class
 */
public static void setSubstanceLAF(String laf) {
    try {
        UIManager.setLookAndFeel(laf);
        UIManager.put(SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS, Boolean.FALSE);
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);

        // Substance forgot to put a border for JTextArea,
        // So we give it the same border that TextField has
        Object border = UIManager.get("TextField.border");
        UIManager.put("TextArea.border", border);
        // Plain title font
        //            SubstanceLookAndFeel.setFontPolicy(new FontPolicy() {
        //                public FontSet getFontSet(String arg0, UIDefaults arg1) {
        //                    FontSet fontSet = new FontSet() {
        //                        public FontUIResource getWindowTitleFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); //this is where the title font changes
        //                        }
        //
        //                        public FontUIResource getTitleFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getSmallFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getMessageFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getMenuFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //
        //                        public FontUIResource getControlFont() {
        //                            return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14));
        //                        }
        //                    };
        //                    return fontSet;
        //                }
        //            });        
    } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException
            | IllegalAccessException ex) {
        Logger.getLogger(GUIToolkit.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ome.formats.importer.gui.OptionsDialog.java

/**
 * Initialize and show the options dialog
 * /*from  www  . ja  va  2s  .  c o  m*/
 * @param config - ImportConfig to store/save settings too
 * @param owner - parent 
 * @param title - dialog title
 * @param modal - modal yes/no
 */
OptionsDialog(ImportConfig config, JFrame owner, String title, boolean modal) {
    super(owner);

    this.owner = owner;

    setLocation(200, 200);
    setTitle(title);
    setModal(modal);
    setResizable(false);
    setSize(new Dimension(dialogWidth, dialogHeight));
    setLocationRelativeTo(owner);

    tabbedPane = new JTabbedPane();
    tabbedPane.setOpaque(false); // content panes must be opaque

    this.config = config;

    oldQuaquaLevel = config.getUseQuaqua();
    oldUserDisableHistory = config.getUserDisableHistory();

    /////////////////////// START MAIN PANEL ////////////////////////

    // Set up the main pane
    double mainPanelTable[][] = { { TableLayout.FILL, 120, 5, 120, TableLayout.FILL }, // columns
            { TableLayout.FILL, 5, 30 } }; // rows     

    mainPanel = GuiCommonElements.addMainPanel(this, mainPanelTable, 10, 10, 10, 10, debug);

    // Buttons at the bottom of the form

    cancelBtn = GuiCommonElements.addButton(mainPanel, "Cancel", 'L', "Cancel", "1, 2, f, c", debug);
    cancelBtn.addActionListener(this);

    okBtn = GuiCommonElements.addButton(mainPanel, "OK", 'Q', "Import", "3, 2, f, c", debug);
    okBtn.addActionListener(this);

    this.getRootPane().setDefaultButton(okBtn);
    GuiCommonElements.enterPressesWhenFocused(okBtn);

    mainPanel.add(tabbedPane, "0,0,4,0");

    /////////////////////// START DEBUG OPTIONS PANEL ////////////////////////

    double debugOptionTable[][] = { { TableLayout.FILL }, // columns
            { 10, TableLayout.PREFERRED, 20, 30, 15, TableLayout.FILL } }; // rows

    debugOptionsPanel = GuiCommonElements.addMainPanel(tabbedPane, debugOptionTable, 0, 10, 10, 10, debug);

    String message = "Choose the level of detail for your log file's data.";
    GuiCommonElements.addTextPane(debugOptionsPanel, message, "0, 1, 0, 0", debug);
    dBox = GuiCommonElements.addComboBox(debugOptionsPanel, "Debug Level: ", debugItems, 'D',
            "Choose the level of detail for your log file's data.", 95, "0,3,F,C", debug);

    int debugLevel = config.getDebugLevel();

    for (int i = 0; i < dBox.getItemCount(); i++) {
        if (((DebugItem) dBox.getItemAt(i)).getLevel() == debugLevel)
            dBox.setSelectedIndex(i);
    }
    dBox.addActionListener(this);

    String description = ((DebugItem) dBox.getSelectedItem()).getDescription();
    descriptionText = GuiCommonElements.addTextPane(debugOptionsPanel, description, "0, 5", debug);
    final Font textFieldFont = (Font) UIManager.get("TextField.font");
    final Font font = new Font(textFieldFont.getFamily(), Font.ITALIC, textFieldFont.getSize());
    descriptionText.setFont(font);

    /////////////////////// START OTHER OPTIONS PANEL ////////////////////////

    double otherOptionTable[][] = { { TableLayout.FILL }, // columns
            { 10, TableLayout.PREFERRED, 20, 30, 15, TableLayout.FILL } }; // rows

    otherOptionsPanel = GuiCommonElements.addMainPanel(tabbedPane, otherOptionTable, 0, 10, 10, 10, debug);

    companionFileCheckbox = GuiCommonElements.addCheckBox(otherOptionsPanel,
            "<html>Attached a text file to each imported" + " file containing all collected metadata.</html>",
            "0,1", debug);

    companionFileCheckbox.setSelected(config.companionFile.get());

    disableHistoryCheckbox = GuiCommonElements.addCheckBox(otherOptionsPanel,
            "<html>Disable Import History. (Improves " + " import speed. Restart required if changed).</html>",
            "0,3", debug);

    disableHistoryCheckbox.setSelected(config.getUserDisableHistory());

    // If disabled by admin in import.config, disable this option
    if (config.getStaticDisableHistory()) {
        disableHistoryCheckbox.setEnabled(false);
    }

    /////////////////////// START FILECHOOSER PANEL ////////////////////////

    // Set up the import panel for tPane, quit, and send buttons

    double fileChooserTable[][] = { { TableLayout.FILL, 120, 5, 120, TableLayout.FILL }, // columns
            { TableLayout.PREFERRED, 15, TableLayout.FILL, 10 } }; // rows

    fileChooserPanel = GuiCommonElements.addMainPanel(tabbedPane, fileChooserTable, 0, 10, 0, 10, debug);

    message = "Switch between single pane view and triple pane view. "
            + "You will need to reboot the importer before your changes will take effect.";
    GuiCommonElements.addTextPane(fileChooserPanel, message, "0, 0, 4, 0", debug);

    // Set up single pane table
    double singlePaneTable[][] = { { 24, 5, TableLayout.FILL }, // columns
            { TableLayout.FILL } }; // rows

    // Panel containing the single pane layout

    singlePanePanel = GuiCommonElements.addMainPanel(fileChooserPanel, singlePaneTable, 0, 0, 0, 0, debug);

    singlePaneBtn = GuiCommonElements.addRadioButton(singlePanePanel, null, 'u', null, "0,0", debug);

    GuiCommonElements.addImagePanel(singlePanePanel, SINGLE_PANE_IMAGE, "2,0", debug);

    fileChooserPanel.add(singlePanePanel, "0, 2, 1, 2");

    // Set up triple pane table
    double triplePaneTable[][] = { { 24, 5, TableLayout.FILL }, // columns
            { TableLayout.FILL } }; // rows

    // Panel containing the triple pane layout

    triplePanePanel = GuiCommonElements.addMainPanel(fileChooserPanel, triplePaneTable, 0, 0, 0, 0, debug);

    triplePaneBtn = GuiCommonElements.addRadioButton(triplePanePanel, null, 'u', null, "0,0", debug);

    GuiCommonElements.addImagePanel(triplePanePanel, TRIPLE_PANE_IMAGE, "2,0", debug);

    fileChooserPanel.add(triplePanePanel, "3, 2, 4, 2");

    ButtonGroup group = new ButtonGroup();
    group.add(singlePaneBtn);
    group.add(triplePaneBtn);

    if (config.getUseQuaqua() == true) {
        triplePaneBtn.setSelected(true);
        singlePaneBtn.setSelected(false);
    } else {
        triplePaneBtn.setSelected(false);
        singlePaneBtn.setSelected(true);
    }

    /////////////////////// START TABBED PANE ////////////////////////

    //if (GuiCommonElements.getIsMac()) tabbedPane.addTab("FileChooser", null, fileChooserPanel, "FileChooser Settings");
    tabbedPane.addTab("Debug", null, debugOptionsPanel, "Debug Settings");
    tabbedPane.addTab("Other", null, otherOptionsPanel, "Other Settings");

    this.add(mainPanel);

    setVisible(true);
}

From source file:org.ecoinformatics.seek.ecogrid.EcogridPreferencesTab.java

private void initButtonPanel() {

    // remember default button font
    final Font defaultUIMgrButtonFont = (Font) UIManager.get("Button.font");

    // now set our custom size, provided it's smaller than the default:
    int buttonFontSize = (defaultUIMgrButtonFont.getSize() < BUTTON_FONT_SIZE)
            ? defaultUIMgrButtonFont.getSize()
            : BUTTON_FONT_SIZE;//from w ww.  j  a  v  a  2  s  .  c om

    final Font BUTTON_FONT = new Font(defaultUIMgrButtonFont.getFontName(), defaultUIMgrButtonFont.getStyle(),
            buttonFontSize);

    UIManager.put("Button.font", BUTTON_FONT);

    refreshButton = new JButton(new ServicesRefreshAction(
            StaticResources.getDisplayString("preferences.data.refresh", "Refresh"), this));
    refreshButton.setMinimumSize(EcogridPreferencesTab.BUTTONDIMENSION);
    refreshButton.setPreferredSize(EcogridPreferencesTab.BUTTONDIMENSION);
    refreshButton.setSize(EcogridPreferencesTab.BUTTONDIMENSION);
    // setMaximumSize was truncating label on osX. I don't know why. 
    // It seems about the same as how SearchUIJPanel does things. -derik
    //refreshButton.setMaximumSize(EcogridPreferencesTab.BUTTONDIMENSION);

    keepExistingCheckbox = new JCheckBox(
            StaticResources.getDisplayString("preferences.data.keepExistingSources", "Keep existing sources"));
    keepExistingCheckbox.setSelected(false);

    JPanel bottomPanel = new JPanel();

    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
    bottomPanel.add(refreshButton);
    bottomPanel.add(keepExistingCheckbox);

    newButtonPanel = new JPanel();
    newButtonPanel.setLayout(new BorderLayout());
    newButtonPanel.add(Box.createVerticalStrut(EcogridPreferencesTab.MARGINGSIZE), BorderLayout.NORTH);
    newButtonPanel.add(bottomPanel, BorderLayout.SOUTH);
    setButtonPanel(newButtonPanel);

    // restore default button font
    if (defaultUIMgrButtonFont != null) {
        UIManager.put("Button.font", defaultUIMgrButtonFont);
    }
}

From source file:org.executequery.util.LookAndFeelLoader.java

private void applyMacSettings() {

    if (UIUtils.isMac()) {

        String[] textComponents = { "TextField", "TextPane", "TextArea", "EditorPane", "PasswordField" };
        for (String textComponent : textComponents) {

            InputMap im = (InputMap) UIManager.get(textComponent + ".focusInputMap");
            im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), DefaultEditorKit.copyAction);
            im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK),
                    DefaultEditorKit.pasteAction);
            im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction);
        }/*from w  w  w .j a  v  a2  s  .c o  m*/

        if (UIUtils.isNativeMacLookAndFeel()) {

            UIManager.put("Table.gridColor", UIUtils.getDefaultBorderColour());
        }

    }

}

From source file:org.geworkbench.engine.ccm.DependencyManager.java

void checkDependency() {
    // in case other component does not like this
    Object oldSetting = UIManager.get("Button.defaultButtonFollowsFocus");
    UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
    JDialog dialog = optionPane.createDialog(null, "Dependency Checking Dialog");

    dialog.setVisible(true);/*from   w ww . j  ava2 s  . co m*/
    Object obj = optionPane.getValue();
    UIManager.put("Button.defaultButtonFollowsFocus", oldSetting); // restore
    if (obj == null) {
        rollBack();
        return;
    }
    String selectedValue = (String) optionPane.getValue();
    if (selectedValue.equals("Continue")) {
        switch (changeFlag) {
        case LOAD:
            updateRequired();
            break;
        case UNLOAD:
            updateDependent();
            break;
        default:
            log.error("invalid flag independency manager");
        }
        return;
    } else { // if not "Continue"
        rollBack();
    }
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Returns background color for panels, as set by Look And Feel.
 * //from   w  w w  . j  a  v a  2s  .c o m
 * @return the background color
 */
public static Color getBackgroundColor() {
    return (Color) UIManager.get("Panel.background");
}