Example usage for javax.swing UIManager getDefaults

List of usage examples for javax.swing UIManager getDefaults

Introduction

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

Prototype

public static UIDefaults getDefaults() 

Source Link

Document

Returns the defaults.

Usage

From source file:com.clank.launcher.Launcher.java

/**
 * Bootstrap./*from   w w w. j  a  v a2s . com*/
 *
 * @param args args
 */
public static void main(String[] args) {
    SimpleLogFormatter.configureGlobalLogger();

    LauncherArguments options = new LauncherArguments();
    try {
        new JCommander(options, args);
    } catch (ParameterException e) {
        System.err.print(e.getMessage());
        System.exit(1);
        return;
    }

    Integer bsVersion = options.getBootstrapVersion();
    log.info(bsVersion != null ? "Bootstrap version " + bsVersion + " detected" : "Not bootstrapped");

    File dir = options.getDir();
    if (dir != null) {
        log.info("Using given base directory " + dir.getAbsolutePath());
    } else {
        dir = new File(".");
        log.info("Using current directory " + dir.getAbsolutePath());
    }

    final File baseDir = dir;

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                UIManager.getDefaults().put("SplitPane.border", BorderFactory.createEmptyBorder());
                Launcher launcher = new Launcher(baseDir);
                new LauncherFrame(launcher).setVisible(true);
            } catch (Throwable t) {
                log.log(Level.WARNING, "Load failure", t);
                SwingHelper.showErrorDialog(null,
                        "Uh oh! The updater couldn't be opened because a " + "problem was encountered.",
                        "Launcher error", t);
            }
        }
    });

}

From source file:Main.java

private static int createDefaultHorizontalAlignment() {
    int swingAlign = SwingConstants.RIGHT;
    String defaultAlignment = UIManager.getDefaults().getString("Label.defaultHorizontalAlignment");
    if (defaultAlignment != null) {
        if ("LEFT".equalsIgnoreCase(defaultAlignment)) {
            swingAlign = SwingConstants.LEFT;
        } else if ("RIGHT".equalsIgnoreCase(defaultAlignment)) {
            swingAlign = SwingConstants.RIGHT;
        } else if ("CENTER".equalsIgnoreCase(defaultAlignment)) {
            swingAlign = SwingConstants.CENTER;
        }/* ww  w  . j a va  2 s.c  o m*/
    }
    return swingAlign;
}

From source file:Main.java

public static void increaseDefaultFont(float multiplier) {
    for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value != null && value instanceof FontUIResource) {
            FontUIResource fontUIResource = (FontUIResource) value;
            UIManager.put(key, fontUIResource.deriveFont(fontUIResource.getSize() * multiplier));
        }/*from www .ja v  a2 s.  co m*/
    }
}

From source file:Main.java

public static void printUIDefaults() {
    UIDefaults uiDefaults = UIManager.getDefaults();
    Enumeration<Object> e = uiDefaults.keys();
    while (e.hasMoreElements()) {
        Object key = e.nextElement();
        Object val = uiDefaults.get(key);
        System.out.println("[" + key.toString() + "]:[" + (null != val ? val.toString() : "(null)") + "]");
    }/*from  w  ww . ja  va2  s .c om*/
}

From source file:Main.java

/**
 * Sets the default UI font style.//  ww  w . ja  va 2 s .  c  om
 * 
 * @param fontStyle
 *            The font style
 * @see Font See Font Javadoc for possible styles
 */
public static void setUIFontStyle(final int fontStyle) {
    for (Enumeration<?> en = UIManager.getDefaults().keys(); en.hasMoreElements();) {
        Object key = en.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof FontUIResource) {
            FontUIResource fontRes = (FontUIResource) value;
            UIManager.put(key, new ProxyLazyValue("javax.swing.plaf.FontUIResource", null,
                    new Object[] { fontRes.getName(), fontStyle, fontRes.getSize() }));
        }
    }
}

From source file:UIUtilities.java

/**
 * Set up the user interface./*from   w  w w . ja  va  2s  .com*/
 */
public static void setupUI() {
    try {
        final String classname = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(classname);
    } catch (Exception e) {
        e.printStackTrace();
    }

    final UIDefaults defaults = UIManager.getDefaults();

    defaults.put("PopupMenu.border", new BorderUIResource.EtchedBorderUIResource(EtchedBorder.RAISED,
            defaults.getColor("controlShadow"), defaults.getColor("controlLtHighlight")));

    final MatteBorder matteborder = new MatteBorder(1, 1, 1, 1, Color.black);
    final EmptyBorder emptyborder = new MatteBorder(2, 2, 2, 2, defaults.getColor("control"));
    final BorderUIResource.CompoundBorderUIResource compBorder = new BorderUIResource.CompoundBorderUIResource(
            emptyborder, matteborder);
    final BorderUIResource.EmptyBorderUIResource emptyBorderUI = new BorderUIResource.EmptyBorderUIResource(0,
            0, 0, 0);
    defaults.put("SplitPane.border", emptyBorderUI);
    defaults.put("Table.scrollPaneBorder", emptyBorderUI);
    defaults.put("ComboBox.border", compBorder);
    defaults.put("TextField.border", compBorder);
    defaults.put("TextArea.border", compBorder);
    defaults.put("CheckBox.border", compBorder);
    defaults.put("ScrollPane.border", emptyBorderUI);

}

From source file:com.googlecode.vfsjfilechooser2.filechooser.AbstractVFSFileSystemView.java

public static AbstractVFSFileSystemView getFileSystemView() {
    useSystemExtensionsHiding = UIManager.getDefaults().getBoolean("FileChooser.useSystemExtensionHiding");
    UIManager.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if (e.getPropertyName().equals("lookAndFeel")) {
                useSystemExtensionsHiding = UIManager.getDefaults()
                        .getBoolean("FileChooser.useSystemExtensionHiding");
            }//from w  w  w.  ja v a2s  . c om
        }
    });

    if (genericFileSystemView == null) {
        genericFileSystemView = new GenericFileSystemView();
    }

    return genericFileSystemView;
}

From source file:UIDefaultsTreeModel.java

public UIDefaultsTreeModel() {
    innerModel = new DefaultTreeModel(rootNode);
    innerModel.insertNodeInto(colorNode, rootNode, 0);
    innerModel.insertNodeInto(borderNode, rootNode, 1);
    innerModel.insertNodeInto(fontNode, rootNode, 2);
    innerModel.insertNodeInto(iconNode, rootNode, 3);
    innerModel.insertNodeInto(otherNode, rootNode, 4);
    UIDefaults defaults = UIManager.getDefaults();
    Enumeration elems = defaults.keys();
    String keyName;//from w w w. ja va  2  s  .co  m
    Object valueForKey;
    while (elems.hasMoreElements()) {
        DefaultMutableTreeNode newKeyNode;
        DefaultMutableTreeNode newValueNode;
        try {
            keyName = elems.nextElement().toString();
            valueForKey = defaults.get(keyName);

            newKeyNode = new DefaultMutableTreeNode(keyName);
            newValueNode = new DefaultMutableTreeNode(valueForKey);

            if (valueForKey instanceof java.awt.Color) {
                innerModel.insertNodeInto(newKeyNode, colorNode, 0);
            } else if (valueForKey instanceof javax.swing.border.Border) {
                innerModel.insertNodeInto(newKeyNode, borderNode, 0);
            } else if (valueForKey instanceof java.awt.Font) {
                innerModel.insertNodeInto(newKeyNode, fontNode, 0);
            } else if (valueForKey instanceof javax.swing.Icon) {
                innerModel.insertNodeInto(newKeyNode, iconNode, 0);
            } else {
                innerModel.insertNodeInto(newKeyNode, otherNode, 0);
            }
            innerModel.insertNodeInto(newValueNode, newKeyNode, 0);
        } catch (NullPointerException e) {
        }
    }
}

From source file:com.diversityarrays.kdxplore.KDXplore.java

static public void setUIfontSize(float multiplier) {
    UIDefaults defaults = UIManager.getDefaults();
    for (Enumeration<?> e = defaults.keys(); e.hasMoreElements();) {
        Object key = e.nextElement();
        Object value = defaults.get(key);
        if (value instanceof Font) {
            Font font = (Font) value;
            int newSize = Math.round(font.getSize() * multiplier);
            if (value instanceof FontUIResource) {
                defaults.put(key, new FontUIResource(font.getName(), font.getStyle(), newSize));
            } else {
                defaults.put(key, new Font(font.getName(), font.getStyle(), newSize));
            }//from w w  w . j av a  2  s. c  o m
        } else if (value instanceof Integer) {
            if ("Tree.rowHeight".equals(key)) { //$NON-NLS-1$
                // System.out.println(key+": "+value);
                Integer rh = (Integer) value;
                rh = (int) (rh * multiplier * 1.4);
                defaults.put(key, rh);
            }
        }
    }
}

From source file:es.emergya.cliente.Mobile.java

@Override
protected void configureUI() {
    UIManager.put("swing.boldMetal", Boolean.FALSE); //$NON-NLS-1$

    UIManager.put("TabbedPane.selected", Color.decode("#B1BEF0"));
    final 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, getLightFont());
        }//from  w  w  w.j  ava 2 s .c o m

    }
    UIManager.put("TableHeader.font", deriveBoldFont(10f));
    UIManager.put("TabbedPane.font", deriveLightFont(9f));
}