Example usage for javax.swing UIDefaults put

List of usage examples for javax.swing UIDefaults put

Introduction

In this page you can find the example usage for javax.swing UIDefaults put.

Prototype

public Object put(Object key, Object value) 

Source Link

Document

Sets the value of key to value for all locales.

Usage

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining to a particular class.
 * // w  w w  .ja v a  2s.  c o  m
 * @param className
 *            fully qualified name of the class of interest
 * @return the UIDefaults of the class named
 */
public static UIDefaults getUIDefaultsOfClass(String className) {
    UIDefaults retVal = new UIDefaults();
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    List<?> listKeys = Collections.list(defaults.keys());
    for (Object key : listKeys) {
        if (key instanceof String && ((String) key).startsWith(className)) {
            String stringKey = (String) key;
            String property = stringKey;
            if (stringKey.contains(".")) { //$NON-NLS-1$
                property = stringKey.substring(stringKey.indexOf(".") + 1); //$NON-NLS-1$
            }
            retVal.put(property, defaults.get(key));
        }
    }
    return retVal;
}

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining
 * to a particular class.//ww  w .  java 2  s  . com
 * 
 * @param className
 *            fully qualified name of the class of interest
 * @return the UIDefaults of the class named
 */
public static UIDefaults getUIDefaultsOfClass(final String className) {
    final UIDefaults retVal = new UIDefaults();
    final UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    final List<?> listKeys = Collections.list(defaults.keys());
    for (final Object key : listKeys) {
        if (key instanceof String && ((String) key).startsWith(className)) {
            final String stringKey = (String) key;
            String property = stringKey;
            if (stringKey.contains(".")) {
                property = stringKey.substring(stringKey.indexOf(".") + 1);
            }
            retVal.put(property, defaults.get(key));
        }
    }
    return retVal;
}

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  2s.  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:MyLookAndFeel.java

protected void initSystemColorDefaults(UIDefaults table) {
    super.initSystemColorDefaults(table);
    table.put("info", new ColorUIResource(255, 255, 225));
}

From source file:Main.java

public Main() {
    super(BoxLayout.Y_AXIS);
    try {//from  w w  w .  ja  v a  2s  .c  o m
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                System.out.println("set");
                break;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    Object o = UIManager.get("TextArea[Enabled+NotInScrollPane].borderPainter");

    UIDefaults paneDefaults = new UIDefaults();
    paneDefaults.put("TextPane.borderPainter", o);

    JTextPane pane = new JTextPane();
    pane.setMargin(new Insets(10, 10, 10, 10));

    pane.putClientProperty("Nimbus.Overrides", paneDefaults);
    pane.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
    pane.setText("this \nis \na \ntest\n");
    add(pane);

}

From source file:ja.lingo.application.util.plaf.JaLingoLookAndFeel.java

protected void initClassDefaults(UIDefaults table) {
    super.initClassDefaults(table);

    table.put("EditorPaneUI", JaLingoEditorPaneUI.class.getName());
    table.put("ListUI", JaLingoListUI.class.getName());
    table.put("ToggleButtonUI", JaLingoToggleButtonUI.class.getName());
}

From source file:ja.lingo.application.util.plaf.JaLingoLookAndFeel.java

protected void initSystemColorDefaults(UIDefaults table) {
    super.initSystemColorDefaults(table);

    table.put("textHighlight", getCurrentTheme().getTextHighlightColor());
    table.put("info", getCurrentTheme().getControlHighlight());
}

From source file:UI.MainViewPanel.java

public JProgressBar getPanel7(Metric7 m7) {

    JProgressBar openPortBar = new JProgressBar(0, 100);
    openPortBar.setValue(m7.totalCriticalCount);
    openPortBar.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    UIDefaults defaults = new UIDefaults();

    Painter foregroundPainter = new MyPainter(new Color(230, 219, 27));
    Painter backgroundPainter = new MyPainter(chartBackgroundColor);
    defaults.put("ProgressBar[Enabled].foregroundPainter", foregroundPainter);
    defaults.put("ProgressBar[Enabled+Finished].foregroundPainter", foregroundPainter);
    defaults.put("ProgressBar[Enabled].backgroundPainter", backgroundPainter);

    openPortBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
    openPortBar.putClientProperty("Nimbus.Overrides", defaults);

    openPortBar.setString("" + m7.totalCriticalCount);
    openPortBar.setStringPainted(true);//  w  w  w  . j  a va 2 s  .c o m

    return openPortBar;
}

From source file:jflowmap.JFlowMapApplet.java

public JFlowMapApplet() {
    instantiated = true;//from w  w  w.j a va  2  s  .co m
    if (!JFlowMapMain.IS_OS_MAC) {
        SwingUtils.initNimbusLF();

        UIDefaults defaults = UIManager.getLookAndFeelDefaults();
        //      defaults.put("Panel.background", new Color(0xf0, 0xf0, 0xf0));
        //      defaults.put("TabbedPane.background", new Color(0xf0, 0xf0, 0xf0));
        defaults.put("background", new Color(0xf0, 0xf0, 0xf0));
        defaults.put("defaultFont", new Font("Arial", Font.PLAIN, 14));
    }

    blockingGlassPane = new BlockingGlassPane();
    setGlassPane(blockingGlassPane);
    blockingGlassPane.setVisible(false);
}

From source file:com.NewJFrame.java

/**
 * Creates new form NewJFrame//from w  w w. jav a  2 s  .co m
 */
public NewJFrame() {
    initComponents();

    textPane.setText("Hello");
    Color bgColor = Color.BLACK;
    UIDefaults defaults = new UIDefaults();
    defaults.put("TextPane[Enabled].backgroundPainter", bgColor);
    textPane.putClientProperty("Nimbus.Overrides", defaults);
    textPane.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
    textPane.setBackground(bgColor);

}