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

public static void main(String[] args) {
    final JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Icon empty = new TreeIcon();
    UIManager.put("Tree.closedIcon", empty);
    UIManager.put("Tree.openIcon", empty);
    UIManager.put("Tree.collapsedIcon", empty);
    UIManager.put("Tree.expandedIcon", empty);
    UIManager.put("Tree.leafIcon", empty);

    JTree jt = new JTree();
    frame.add(jt);/*from   ww  w.  j a  v a 2  s  . c o  m*/
    frame.pack();
    frame.setSize(300, 400);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("UIDefaults Example");
    frame.setDefaultCloseOperation(3);//from  ww w. j  a va  2s  . c om
    Container c = frame.getContentPane();
    UIManager.put("Button.background", Color.red);
    UIManager.put("Button.foreground", Color.white);
    Font f = new Font("Serif", Font.ITALIC, 24);
    UIManager.put("Button.font", f);

    JButton north = new JButton("North");
    JButton south = new JButton("South");
    JButton east = new JButton("East");
    JButton west = new JButton("West");
    JButton center = new JButton("Center");
    c.add(north, BorderLayout.NORTH);
    c.add(south, BorderLayout.SOUTH);
    c.add(east, BorderLayout.EAST);
    c.add(west, BorderLayout.WEST);
    c.add(center, BorderLayout.CENTER);
    frame.pack();
    frame.show();

}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Active Example");
    UIManager.put("LabelFactory", new ActiveLabel());
    final JPanel panel = new JPanel();
    JButton button = new JButton("Get");
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JLabel label = (JLabel) UIManager.get("LabelFactory");
            panel.add(label);//ww  w .  ja  va 2s  .  com
            panel.revalidate();
        }
    };
    button.addActionListener(actionListener);

    Container contentPane = frame.getContentPane();
    contentPane.add(panel, BorderLayout.CENTER);
    contentPane.add(button, BorderLayout.SOUTH);
    frame.setSize(200, 200);
    frame.setVisible(true);
}

From source file:LookAndFeelMakeIcon.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Lazy Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Object iconObject = LookAndFeel.makeIcon(LookAndFeelMakeIcon.class, "yourFile.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);//from   w  w w  .jav a2 s.  c  o m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    String[] items = new String[] { "", "Apple", "Banana", "Carrot" };
    Color bgColor = UIManager.getColor("TextField.background");

    UIManager.put("ComboBox.selectionBackground", new ColorUIResource(bgColor));

    JComboBox<String> combo1 = new JComboBox<>(items);
    combo1.setPrototypeDisplayValue("XXXXXXXXXXXXXXX");
    combo1.setEditable(true);//from   www .  j av a  2s  .c  om
    combo1.setSelectedIndex(-1);

    JComboBox<String> combo2 = new JComboBox<>(items);
    combo2.setPrototypeDisplayValue("XXXXXXXXXXXXXXX");
    combo2.setEditable(false);
    combo2.setSelectedIndex(-1);
    combo2.setBackground(bgColor);

    JFrame frame = new JFrame();
    Container c = frame.getContentPane();
    c.setLayout(new FlowLayout());
    c.add(combo1);
    c.add(combo2);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 100);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Lazy Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Object iconObject = LookAndFeel.makeIcon(MainClass.class, "yourImage.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    Integer fifteen = new Integer(15);
    Object lazyArgs[] = new Object[] { Color.GREEN, Boolean.TRUE, fifteen, fifteen };
    Object lazyDiamond = new UIDefaults.ProxyLazyValue("DiamondIcon", lazyArgs);
    UIManager.put("Tree.openIcon", lazyDiamond);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);// www .ja va 2 s  . com
    frame.setVisible(true);
}

From source file:ActiveSample.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Active Example");

    UIManager.put(LABEL_FACTORY, new ActiveLabel());

    final JPanel panel = new JPanel();

    JButton button = new JButton("Get");

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JLabel label = (JLabel) UIManager.get(LABEL_FACTORY);
            panel.add(label);//from  ww w .j av  a 2  s.com
            panel.revalidate();
        }
    };
    button.addActionListener(actionListener);

    Container contentPane = frame.getContentPane();
    contentPane.add(panel, BorderLayout.CENTER);
    contentPane.add(button, BorderLayout.SOUTH);
    frame.setSize(200, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    final String LABEL_FACTORY = "LabelFactory";

    JFrame frame = new JFrame("Active Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    UIManager.put(LABEL_FACTORY, new ActiveLabel());

    final JPanel panel = new JPanel();

    JButton button = new JButton("Get");

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            JLabel label = (JLabel) UIManager.get(LABEL_FACTORY);
            panel.add(label);// w ww .  ja va2s . co  m
            panel.revalidate();
        }
    };
    button.addActionListener(actionListener);

    frame.add(panel, BorderLayout.CENTER);
    frame.add(button, BorderLayout.SOUTH);
    frame.setSize(200, 200);
    frame.setVisible(true);
}

From source file:LazySample.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Lazy Example");

    Object iconObject = LookAndFeel.makeIcon(LazySample.class, "World.gif");
    UIManager.put("Tree.leafIcon", iconObject);

    Integer fifteen = new Integer(15);
    Object lazyArgs[] = new Object[] { Color.green, Boolean.TRUE, fifteen, fifteen };
    Object lazyDiamond = new UIDefaults.ProxyLazyValue("DiamondIcon", lazyArgs);
    UIManager.put("Tree.openIcon", lazyDiamond);

    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);

    Container contentPane = frame.getContentPane();
    contentPane.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(200, 200);/*from w ww  .j a va 2  s  . c om*/
    frame.setVisible(true);
}

From source file:TreeNodeVector.java

public static void main(final String args[]) {
    UIManager.put("Tree.openIcon", new ImageIcon("yourFile.gif"));

    JFrame frame = new JFrame("JTreeSample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Vector<String> v1 = new TreeNodeVector<String>("Two", new String[] { "Mercury", "Venus", "Mars" });
    Vector<Object> v2 = new TreeNodeVector<Object>("Three");
    v2.add(System.getProperties());
    v2.add(v1);/*from   ww w .  j  a  v a2s .com*/
    Object rootNodes[] = { v1, v2 };
    Vector<Object> rootVector = new TreeNodeVector<Object>("Root", rootNodes);
    JTree tree = new JTree(rootVector);
    frame.add(new JScrollPane(tree), BorderLayout.CENTER);

    frame.setSize(300, 300);
    frame.setVisible(true);

}