Example usage for javax.swing UIManager getInstalledLookAndFeels

List of usage examples for javax.swing UIManager getInstalledLookAndFeels

Introduction

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

Prototype

public static LookAndFeelInfo[] getInstalledLookAndFeels() 

Source Link

Document

Returns an array of LookAndFeelInfo s representing the LookAndFeel implementations currently available.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    UIManager.LookAndFeelInfo plaf[] = UIManager.getInstalledLookAndFeels();
    for (int i = 0, n = plaf.length; i < n; i++) {
        System.out.println("Name: " + plaf[i].getName());
        System.out.println("  Class name: " + plaf[i].getClassName());
    }/*w w  w . ja v a 2 s  .co m*/
}

From source file:ListPlafs.java

public static void main(String args[]) {
    UIManager.LookAndFeelInfo plaf[] = UIManager.getInstalledLookAndFeels();
    for (int i = 0, n = plaf.length; i < n; i++) {
        System.out.println("Name: " + plaf[i].getName());
        System.out.println("  Class name: " + plaf[i].getClassName());
    }// w  ww  .j  av a2 s.  c o m
    System.exit(0);
}

From source file:Main.java

public static void main(String[] args) {

    LookAndFeelInfo[] lafList = UIManager.getInstalledLookAndFeels();

    for (LookAndFeelInfo lafInfo : lafList) {
        String name = lafInfo.getName();
        String className = lafInfo.getClassName();
        System.out.println("Name: " + name + ", Class Name: " + className);
    }//from   ww w  .  j  av a2  s.  c  om
}

From source file:Main.java

public static void main(String[] args) {
    System.out.println("  " + UIManager.getLookAndFeel().getName());

    UIManager.LookAndFeelInfo[] inst = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < inst.length; i++) {
        System.out.println("  " + inst[i].getName());
    }//from ww w . j a v a 2  s .c o m

    LookAndFeel[] aux = UIManager.getAuxiliaryLookAndFeels();
    if (aux != null) {
        for (int i = 0; i < aux.length; i++) {
            System.out.println("  " + aux[i].getName());
        }
    } else {
        System.out.println("  <NONE>");
    }
    System.out.println("  " + UIManager.getCrossPlatformLookAndFeelClassName());
    System.out.println("  " + UIManager.getSystemLookAndFeelClassName());
}

From source file:UIManagerDefaults.java

public static void main(String[] args) {
    System.out.println("Default L&F:");
    System.out.println("  " + UIManager.getLookAndFeel().getName());

    UIManager.LookAndFeelInfo[] inst = UIManager.getInstalledLookAndFeels();
    System.out.println("Installed L&Fs: ");
    for (int i = 0; i < inst.length; i++) {
        System.out.println("  " + inst[i].getName());
    }/* w  w w  .ja  va  2 s . co m*/

    LookAndFeel[] aux = UIManager.getAuxiliaryLookAndFeels();
    System.out.println("Auxiliary L&Fs: ");
    if (aux != null) {
        for (int i = 0; i < aux.length; i++) {
            System.out.println("  " + aux[i].getName());
        }
    } else {
        System.out.println("  <NONE>");
    }

    System.out.println("Cross-Platform:");
    System.out.println(UIManager.getCrossPlatformLookAndFeelClassName());

    System.out.println("System:");
    System.out.println(UIManager.getSystemLookAndFeelClassName());

    System.exit(0);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < infos.length; i++) {
        LookAndFeelInfo info = infos[i];
        System.out.println(info.getClassName());

    }//from ww  w .ja va2s  .  c  o  m

}

From source file:edu.gmu.isa681.client.Main.java

public static void main(String[] args) {
    log.info("Setting look and feel...");

    try {/*from w ww .jav a2s .c o  m*/
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }

    } catch (Exception ex1) {
        log.warn(ex1.getMessage(), ex1);
        log.warn("Nimbus is not available.");
        log.warn("Switching to system look and feel");
        log.warn("Some GUI discrepancies may occur!");

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex2) {
            log.error(ex2.getMessage(), ex2);
            log.error("Could not setup a look and feel.");
            System.exit(1);
        }
    }

    log.info("Initializing GUI...");

    final JFrame frame = new JFrame();
    frame.setTitle("GoForward");
    frame.setBackground(new Color(0, 100, 0));
    UIManager.put("nimbusBase", new Color(0, 100, 0));
    //UIManager.put("nimbusBlueGrey", new Color(0, 100, 0));
    UIManager.put("control", new Color(0, 100, 0));

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            frame.setPreferredSize(frame.getSize());
        }
    });

    Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    if (dim.width < 1366) {
        frame.setPreferredSize(new Dimension(800, 600));
    } else {
        frame.setPreferredSize(new Dimension(1200, 700));
    }

    //frame.setResizable(false);
    frame.setLocationByPlatform(true);
    frame.pack();

    Client client = new Client("localhost", Constants.SERVER_PORT);
    Controller controller = new Controller(client, frame);
    controller.applicationStarted();

    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    log.info("Started");
}

From source file:Main.java

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

    JPanel gui = new JPanel(new BorderLayout(5, 5));

    JPanel plafComponents = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 3));
    plafComponents.setBorder(new TitledBorder("FlowLayout(FlowLayout.RIGHT, 3,3)"));

    UIManager.LookAndFeelInfo[] plafInfos = UIManager.getInstalledLookAndFeels();
    String[] plafNames = new String[plafInfos.length];
    for (int ii = 0; ii < plafInfos.length; ii++) {
        plafNames[ii] = plafInfos[ii].getName();
    }/*from w w w.  j  av  a  2 s. co  m*/
    JComboBox plafChooser = new JComboBox(plafNames);
    plafComponents.add(plafChooser);

    JCheckBox pack = new JCheckBox("Pack on PLAF change", true);
    plafComponents.add(pack);

    plafChooser.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int index = plafChooser.getSelectedIndex();
            try {
                UIManager.setLookAndFeel(plafInfos[index].getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
                if (pack.isSelected()) {
                    frame.pack();
                    frame.setMinimumSize(frame.getSize());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    gui.add(plafComponents, BorderLayout.NORTH);

    JPanel dynamicLabels = new JPanel(new BorderLayout(4, 4));
    dynamicLabels.setBorder(new TitledBorder("BorderLayout(4,4)"));
    gui.add(dynamicLabels, BorderLayout.WEST);

    final JPanel labels = new JPanel(new GridLayout(0, 2, 3, 3));
    labels.setBorder(new TitledBorder("GridLayout(0,2,3,3)"));

    JButton addNew = new JButton("Add Another Label");
    dynamicLabels.add(addNew, BorderLayout.NORTH);
    addNew.addActionListener(new ActionListener() {

        private int labelCount = 0;

        public void actionPerformed(ActionEvent ae) {
            labels.add(new JLabel("Label " + ++labelCount));
            frame.validate();
        }
    });

    dynamicLabels.add(new JScrollPane(labels), BorderLayout.CENTER);

    String[] header = { "Name", "Value" };
    String[] a = new String[0];
    String[] names = System.getProperties().stringPropertyNames().toArray(a);
    String[][] data = new String[names.length][2];
    for (int ii = 0; ii < names.length; ii++) {
        data[ii][0] = names[ii];
        data[ii][1] = System.getProperty(names[ii]);
    }
    DefaultTableModel model = new DefaultTableModel(data, header);
    JTable table = new JTable(model);

    JScrollPane tableScroll = new JScrollPane(table);
    Dimension tablePreferred = tableScroll.getPreferredSize();
    tableScroll.setPreferredSize(new Dimension(tablePreferred.width, tablePreferred.height / 3));

    JPanel imagePanel = new JPanel(new GridBagLayout());
    JLabel imageLabel = new JLabel("test");
    imagePanel.add(imageLabel, null);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tableScroll, new JScrollPane(imagePanel));
    gui.add(splitPane, BorderLayout.CENTER);

    frame.setContentPane(gui);
    frame.pack();
    frame.setVisible(true);
}

From source file:ChangeLook.java

public static void main(String args[]) {
    final JFrame frame = new JFrame("Change Look");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            String lafClassName = null;
            lafClassName = actionEvent.getActionCommand();
            String finalLafClassName = lafClassName;
            try {
                UIManager.setLookAndFeel(finalLafClassName);
                SwingUtilities.updateComponentTreeUI(frame);
            } catch (Exception exception) {
                JOptionPane.showMessageDialog(frame, "Can't change look and feel", "Invalid PLAF",
                        JOptionPane.ERROR_MESSAGE);
            }//from   w  w w  . j  ava  2 s  . c o  m

        }
    };

    UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels();

    JComboBox comboBox = new JComboBox(new String[] { "a", "b" });

    JPanel panel = new JPanel();

    for (int i = 0, n = looks.length; i < n; i++) {
        JButton button = new JButton(looks[i].getName());
        button.setActionCommand(looks[i].getClassName());
        button.addActionListener(actionListener);
        panel.add(button);
    }

    frame.add(comboBox, BorderLayout.NORTH);
    frame.add(panel, BorderLayout.SOUTH);
    frame.setSize(350, 150);
    frame.setVisible(true);

}

From source file:MainClass.java

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

    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Object source = actionEvent.getSource();
            String lafClassName = null;
            if (source instanceof JComboBox) {
                JComboBox comboBox = (JComboBox) source;
                lafClassName = (String) comboBox.getSelectedItem();
            } else if (source instanceof JButton) {
                lafClassName = actionEvent.getActionCommand();
            }/*  w  w w.j a v  a 2s  .com*/
            if (lafClassName != null) {
                final String finalLafClassName = lafClassName;
                try {
                    UIManager.setLookAndFeel(finalLafClassName);
                    SwingUtilities.updateComponentTreeUI(frame);
                } catch (Exception exception) {
                    JOptionPane.showMessageDialog(frame, "Can't change look and feel", "Invalid PLAF",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    };

    UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels();

    DefaultComboBoxModel model = new DefaultComboBoxModel();
    JComboBox comboBox = new JComboBox(model);

    JPanel panel = new JPanel();

    for (int i = 0, n = looks.length; i < n; i++) {
        JButton button = new JButton(looks[i].getName());
        model.addElement(looks[i].getClassName());
        button.setActionCommand(looks[i].getClassName());
        button.addActionListener(actionListener);
        panel.add(button);
    }

    comboBox.addActionListener(actionListener);

    frame.add(comboBox, BorderLayout.NORTH);
    frame.add(panel, BorderLayout.SOUTH);
    frame.setSize(350, 150);
    frame.setVisible(true);
}