List of usage examples for javax.swing UIManager setLookAndFeel
@SuppressWarnings("deprecation") public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
From source file:Main.java
public static void main(final String args[]) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(300, 300);/*from w w w.jav a 2 s . c om*/ f.setLocationRelativeTo(null); f.setUndecorated(true); f.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); JPanel panel = new JPanel(); panel.setBackground(java.awt.Color.white); f.setContentPane(panel); MetalLookAndFeel.setCurrentTheme(new MyDefaultMetalTheme()); try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } SwingUtilities.updateComponentTreeUI(f); f.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); }// w ww . j a va 2s. co 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:ColoredToolTipExample.java
public static void main(String args[]) { try {//from w ww . j a va 2 s . c om UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } ColoredToolTipExample f = new ColoredToolTipExample(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setSize(300, 100); f.show(); }
From source file:MainClass.java
public static void main(String args[]) { SynthLookAndFeel synth = new SynthLookAndFeel(); try {//w w w. j a va2s . c o m Class aClass = MainClass.class; InputStream is = aClass.getResourceAsStream("config.xml"); if (is == null) { System.err.println("Unable to find theme configuration"); System.exit(-1); } synth.load(is, aClass); } catch (ParseException e) { System.err.println("Unable to load theme configuration"); System.exit(-2); } try { UIManager.setLookAndFeel(synth); } catch (javax.swing.UnsupportedLookAndFeelException e) { System.err.println("Unable to change look and feel"); System.exit(-3); } JFrame frame = new JFrame("Synth Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton("Hello, Synth"); frame.add(button, BorderLayout.CENTER); JTextField textField = new JTextField(); frame.add(textField, BorderLayout.SOUTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:edu.gmu.isa681.client.Main.java
public static void main(String[] args) { log.info("Setting look and feel..."); try {// ww w. j av a 2 s . c om 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:net.freedom.gj.example.Main.java
public static void main(String[] args) { try {//from www . j a v a 2s . c o m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { Logger.getLogger(EmployeeView.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("Welcome to EL entity mapper demonstration.\n"); AbstractApplicationContext ctx = new ClassPathXmlApplicationContext( new String[] { "net/freedom/gj/example/mapping/mapping-configuration.xml" }); ctx.registerShutdownHook(); }
From source file:Main.java
public static void main(String[] args) { try {//from w w w. ja va 2s. c om UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } SwingUtilities.invokeLater(() -> { Main frame = new Main(); frame.pack(); frame.setVisible(true); frame.setExtendedState(frame.MAXIMIZED_BOTH); }); }
From source file:Main.java
public static void main(String[] args) throws Exception { String[] properties = { "os.name", "java.version", "java.vm.version", "java.vendor" }; for (String property : properties) { System.out.println(property + ": " + System.getProperty(property)); }//w ww . j av a 2 s. c om JFileChooser jfc = new JFileChooser(); jfc.showOpenDialog(null); jfc.addChoosableFileFilter(new FileFilter() { @Override public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith(".obj"); } @Override public String getDescription() { return "Wavefront OBJ (*.obj)"; } @Override public String toString() { return getDescription(); } }); int result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(jfc); jfc.showOpenDialog(null); result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?"); result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?"); for (UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(jfc); break; } } jfc.showOpenDialog(null); result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?"); }
From source file:br.com.ant.system.app.AntSystemApp.java
public static void main(String[] args) { try {//from w w w . j a va 2 s. c om if (SystemUtils.IS_OS_WINDOWS) { UIManager.setLookAndFeel(WindowsClassicLookAndFeel.class.getName()); } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } ColoniaFormigasView frame = new ColoniaFormigasView(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); DisplayMode mode = devices[0].getDisplayMode(); int height = mode.getHeight(); int width = mode.getWidth(); frame.setSize(width, height - 30); frame.setVisible(true); } catch (Exception e) { throw new RuntimeException(e); } }
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(); }/*from w ww. j a v a2 s . 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); }