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:GetIt.java

public static void main(String args[]) throws Exception {
    JMenu it = new JMenu();
    String classID = it.getUIClassID();
    System.out.println(classID);/* w  w w  . j  a  v  a 2s. c o m*/
    String className = (String) UIManager.get(classID);
    System.out.println(className);
    Class.forName(className);
    System.out.println(System.getProperty("swing.defaultlaf"));
    System.out.println(System.getProperty("swing.auxiliarylaf"));
    System.out.println(System.getProperty("swing.plaf.multiplexinglaf"));
    System.out.println(System.getProperty("swing.installedlafs"));
}

From source file:Main.java

public static void main(String[] argv) {
    Object lazyValue = new UIDefaults.LazyValue() {
        public Object createValue(UIDefaults table) {
            return new JPanel();
        }/*from   w w  w  .j  a  v a  2  s .c  om*/
    };
    UIManager.put("key", lazyValue);
    Object value = UIManager.get("key");
}

From source file:Main.java

public static void main(String[] argv) {
    Object activeValue = new UIDefaults.ActiveValue() {
        public Object createValue(UIDefaults table) {
            return new Date();
        }/*from  ww  w  . j  a  va  2 s.co  m*/
    };

    UIManager.put("key", activeValue);

    Date d1 = (Date) UIManager.get("key");
    Date d2 = (Date) UIManager.get("key");
    boolean b = d1.equals(d2); // false
}

From source file:ComponentHier.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JComponent Hierarchy");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Font font = (Font) UIManager.get("Tree.font");
    font = new Font(font.getFontName(), Font.BOLD, font.getSize() - 3);
    UIManager.put("Tree.font", font);

    Vector jEditorPaneVector = new NamedVector("JEditorPane", new Object[] { "JTextPane" });

    Vector jTextFieldVector = new NamedVector("JTextField", new Object[] { "JPasswordField" });

    Vector jTextComponentVector = new NamedVector("JTextComponent",
            new Object[] { jEditorPaneVector, "JTextArea", jTextFieldVector });

    Vector jLayeredPaneVector = new NamedVector("JLayeredPane", new Object[] { "JDesktopPane" });

    Vector jToggleButtonVector = new NamedVector("JToggleButton", new Object[] { "JCheckBox", "JRadioButton" });

    Vector jMenuItemVector = new NamedVector("JMenuItem",
            new Object[] { "JCheckBoxMenuItem", "JMenu", "JRadioButtonMenuItem" });

    Vector abstractButtonVector = new NamedVector("Abstract Button",
            new Object[] { "JButton", jMenuItemVector, jToggleButtonVector });

    Object jComponentNodes[] = { abstractButtonVector, "JColorChooser", "JComboBox", "JFileChooser",
            "JInternalFrame", "JLabel", jLayeredPaneVector, "JList", "JMenuBar", "JOptionPane", "JPanel",
            "JPopupMenu", "JProgressBar", "JRootPane", "JScrollBar", "JScrollPane", "JSeparator", "JSlider",
            "JSplitPane", "JTabbedPane", "JTable", jTextComponentVector, "JToolBar", "JTree", "JViewPort" };
    Vector jComponentVector = new NamedVector("JComponent", jComponentNodes);

    Object rootNodes[] = { jComponentVector };
    Vector rootVector = new NamedVector("Root", rootNodes);

    JTree tree = new JTree(rootVector);
    tree.putClientProperty("JTree.lineStyle", "Angled");

    JScrollPane scrollPane = new JScrollPane(tree);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setSize(250, 480);/*  www. jav  a  2  s . c o m*/
    frame.setVisible(true);
}

From source file:ActiveSample.java

public static void main(String args[]) {
    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  w w.j  a  v a  2s.c o  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: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);// w w  w  . j  av  a2s  .c  o  m
            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: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  a  v  a  2 s.co  m*/
            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);/*from w  ww.ja va2 s  .  c  o  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:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Undo Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);

    UndoManager manager = new UndoManager();
    textArea.getDocument().addUndoableEditListener(manager);

    JToolBar toolbar = new JToolBar();
    JButton undoButton = new JButton(
            new UndoAction(manager, (String) UIManager.get("AbstractUndoableEdit.undoText")));
    toolbar.add(undoButton);//  ww  w.  j a va2  s  . c  om

    Container content = frame.getContentPane();
    content.add(toolbar, BorderLayout.NORTH);
    content.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);

}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Undo Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);

    UndoManager manager = new UndoManager();
    textArea.getDocument().addUndoableEditListener(manager);

    JToolBar toolbar = new JToolBar();
    JButton undoButton = new JButton(
            new UndoAction(manager, (String) UIManager.get("AbstractUndoableEdit.undoText")));
    toolbar.add(undoButton);//  w ww.  j a  v  a  2s . c om

    JButton redoButton = new JButton(
            new RedoAction(manager, (String) UIManager.get("AbstractUndoableEdit.redoText")));
    toolbar.add(redoButton);

    Container content = frame.getContentPane();
    content.add(toolbar, BorderLayout.NORTH);
    content.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);

}