Example usage for javax.swing UIManager put

List of usage examples for javax.swing UIManager put

Introduction

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

Prototype

public static Object put(Object key, Object value) 

Source Link

Document

Stores an object in the developer defaults.

Usage

From source file:Main.java

/** 
 * Adjust all fonts for displaying to the given size.
 * <br>Use with care!//from  w w  w .j  a  v a2s  .  c o  m
 */
public static void setUIFontSize(final int size) {

    final java.util.Enumeration<Object> keys = UIManager.getLookAndFeelDefaults().keys();
    while (keys.hasMoreElements()) {
        final Object key = keys.nextElement();
        final Object value = UIManager.get(key);
        if (value instanceof Font) {
            final Font ifont = (Font) value;
            final Font ofont = ifont.deriveFont((float) size);
            UIManager.put(key, ofont);
        }
    }
}

From source file:JProgressBarDemo.java

public JProgressBarDemo() {
    super("JProgressBar Demo");
    setSize(300, 100);/*from w w  w.j  av  a  2  s. co m*/

    UIManager.put("ProgressBar.selectionBackground", Color.black);
    UIManager.put("ProgressBar.selectionForeground", Color.white);
    UIManager.put("ProgressBar.foreground", new Color(8, 32, 128));

    progressBar = new JProgressBar();
    progressBar.setMinimum(minValue);
    progressBar.setMaximum(maxValue);
    progressBar.setStringPainted(true);

    JButton start = new JButton("Start");
    start.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Thread runner = new Thread() {
                public void run() {
                    counter = minValue;
                    while (counter <= maxValue) {
                        Runnable runme = new Runnable() {
                            public void run() {
                                progressBar.setValue(counter);
                            }
                        };
                        SwingUtilities.invokeLater(runme);
                        counter++;
                        try {
                            Thread.sleep(100);
                        } catch (Exception ex) {
                        }
                    }
                }
            };
            runner.start();
        }
    });

    getContentPane().add(progressBar, BorderLayout.CENTER);
    getContentPane().add(start, BorderLayout.WEST);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}

From source file:LocationSensitiveDemo.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                increaseFont("Tree.font");
                increaseFont("Label.font");
                increaseFont("ComboBox.font");
                increaseFont("List.font");
            } catch (Exception e) {
            }// w w w.  j  a  v a  2  s.  com

            // Turn off metal's use of bold fonts
            UIManager.put("swing.boldMetal", Boolean.FALSE);
            createAndShowGUI();
        }
    });
}

From source file:Main.java

public JComponent makeUI() {
    UIManager.put("TabbedPane.tabInsets", new Insets(2, 2, 2, 50));
    final JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("A", new JPanel());

    JPanel p = new JPanel(new BorderLayout());
    p.add(new JLayer<JTabbedPane>(tabbedPane, new CloseableTabbedPaneLayerUI()));
    p.add(new JButton(new AbstractAction("add tab") {
        @Override// w w w  . ja v  a2 s. c  om
        public void actionPerformed(ActionEvent e) {
            tabbedPane.addTab("test", new JPanel());
        }
    }), BorderLayout.SOUTH);
    return p;
}

From source file:Main.java

public Main() {
    UIManager.put("TabbedPane.contentBorderInsets", new InsetsUIResource(1, 0, 0, 0));
    UIManager.put("TabbedPane.contentAreaColor", new ColorUIResource(Color.GREEN));
    UIManager.put("TabbedPane.focus", new ColorUIResource(Color.ORANGE));
    UIManager.put("TabbedPane.selected", new ColorUIResource(Color.YELLOW));
    UIManager.put("TabbedPane.darkShadow", new ColorUIResource(Color.DARK_GRAY));
    UIManager.put("TabbedPane.borderHightlightColor", new ColorUIResource(Color.LIGHT_GRAY));
    UIManager.put("TabbedPane.light", new ColorUIResource(Color.WHITE));
    UIManager.put("TabbedPane.tabAreaBackground", new ColorUIResource(Color.CYAN));
    UIManager.put("ToolTip.background", Color.WHITE);
    UIManager.put("ToolTip.border", new BorderUIResource(new LineBorder(Color.BLACK)));
    this.updateUI();

    this.setBackground(Color.BLUE);

    JPanel testPanel = new JPanel();
    testPanel.setLayout(new BorderLayout());
    testPanel.add(new JLabel("Hello World"), BorderLayout.NORTH);
    testPanel.add(new JTextArea("Looks nice out there :)"), BorderLayout.CENTER);

    JPanel testPanel2 = new JPanel();
    testPanel2.setLayout(new BorderLayout());
    testPanel2.add(new JLabel("Good Bye World"), BorderLayout.NORTH);
    testPanel2.add(new JTextArea("OK"), BorderLayout.CENTER);

    this.addTab("Hello World", testPanel);
    this.addTab("World", testPanel2);
}

From source file:Main.java

@Override
public void updateUI() {
    super.updateUI();
    UIManager.put("ComboBox.squareButton", Boolean.FALSE);
    setUI(new BasicComboBoxUI() {
        @Override/*w  ww .j av  a2 s .  com*/
        protected JButton createArrowButton() {
            JButton b = new JButton();
            b.setBorder(BorderFactory.createEmptyBorder());
            b.setVisible(false);
            return b;
        }
    });
    setBorder(BorderFactory.createLineBorder(Color.GRAY));
}

From source file:components.TextInputDemo.java

public static void main(String[] args) {
    //Schedule a job for the event dispatch thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            //Turn off metal's use of bold fonts
            UIManager.put("swing.boldMetal", Boolean.FALSE);
            createAndShowGUI();/*from   ww  w .jav a 2s.c  om*/
        }
    });
}

From source file:Main.java

public static void setFont(Font f) {
    // Font f = new Font("Tahoma",Font.PLAIN,11);
    UIManager.put("TextField.font", f);
    UIManager.put("TextArea.font", f);
    UIManager.put("Label.font", f);
    UIManager.put("ComboBox.font", f);
    UIManager.put("MenuBar.font", f);
    UIManager.put("Menu.font", f);
    UIManager.put("ToolTip.font", f);
    UIManager.put("MenuItem.font", f);
    UIManager.put("List.font", f);
    UIManager.put("Button.font", f);
    UIManager.put("Table.font", f);
}

From source file:de.fhg.igd.swingrcp.SwingRCPUtilities.java

/**
 * Swing setup, should be called before any AWT/Swing Component is created
 *//*ww w . ja  v a2 s . com*/
public static void setup() {
    if (!initialized) {
        // set UIManager class loader to allow it to find custom LaFs
        UIManager.put("ClassLoader", SwingRCPUtilities.class.getClassLoader());

        // reduce flicker on Windows
        System.setProperty("sun.awt.noerasebackground", "true");

        // setup look and feel
        setupLookAndFeel();

        initialized = true;
    }
}

From source file:Main.java

/**
 * Workaround for Bug#5063999./*from   w  w w . j a v  a2s .c  om*/
 */
public static void installDefaults() {
    String defaultlaf = System.getProperty("swing.defaultlaf");
    if (defaultlaf == null || defaultlaf.length() == 0) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | UnsupportedLookAndFeelException | IllegalAccessException
                | InstantiationException ex) {
            // NO-OP
        }
    }
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    UIManager.put(FORMATTED_TEXTFIELD_FONT_KEY, UIManager.get(TEXTFIELD_FONT_KEY));
    UIManager.put(FORMATTED_TEXTFIELD_INACTIVE_BACKGROUND_KEY,
            UIManager.get(TEXTFIELD_INACTIVE_BACKGROUND_KEY));
    UIManager.put(PASSWORDFIELD_FONT_KEY, UIManager.get(TEXTFIELD_FONT_KEY));
    //    try {
    //      UIManager.put(LafWidget.TABBED_PANE_PREVIEW_PAINTER,
    //          new DefaultTabPreviewPainter() {
    //
    //            /**
    //             * {@inheritDoc}
    //             */
    //            @Override
    //            public TabOverviewKind getOverviewKind(JTabbedPane tabPane) {
    //              return TabOverviewKind.ROUND_CAROUSEL;
    //              // return TabOverviewKind.MENU_CAROUSEL;
    //            }
    //          });
    //      UIManager.put(LafWidget.COMPONENT_PREVIEW_PAINTER,
    //          new DefaultPreviewPainter());
    //      UIManager.put(LafWidget.TEXT_EDIT_CONTEXT_MENU, Boolean.TRUE);
    //      // UIManager.put(LafWidget.COMBO_BOX_NO_AUTOCOMPLETION, Boolean.TRUE);
    //    } catch (Throwable ignored) {
    //      // substance may not be available.
    //    }
}