List of usage examples for javax.swing UIManager getInstalledLookAndFeels
public static LookAndFeelInfo[] getInstalledLookAndFeels()
From source file:Main.java
public static void lookWindows(Component comp) { UIManager.LookAndFeelInfo[] looks = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo look : looks) { if (look.getClassName().matches("(?i).*windows.*")) { try { UIManager.setLookAndFeel(look.getClassName()); // UIManager.put("ProgressBar.background", Color.DARK_GRAY); // UIManager.put("ProgressBar.foreground", Color.DARK_GRAY); // UIManager.put("ProgressBar.selectionBackground",Color.DARK_GRAY); // UIManager.put("ProgressBar.selectionForeground",Color.DARK_GRAY); // UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaBlackEyeLookAndFeel"); // UIManager.put("Synthetica.window.opaque", false); // UIManager.put("Synthetica.window.shape", ""); // UIManager.put("Panel.background", Color.decode("#a5ddfb")); // UIManager.put("RadioButton.background", Color.decode("#a5ddfb")); // UIManager.put("CheckBox.background", Color.decode("#a5ddfb")); // UIManager.put("MenuBar.background", Color.decode("#a5ddfb")); SwingUtilities.updateComponentTreeUI(comp); return; } catch (Exception e) { e.printStackTrace();//from w w w . ja va 2s. c o m } } } }
From source file:Main.java
public static void setNimbusLookAndFeel() { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (ClassNotFoundException e) { e.printStackTrace();/*from w ww .jav a2 s . c o m*/ } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } break; } } }
From source file:Main.java
public static void lookNimbus(Component comp) { UIManager.LookAndFeelInfo[] looks = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo look : looks) { if (look.getClassName().matches("(?i).*nimbus.*")) { try { UIManager.setLookAndFeel(look.getClassName()); // UIManager.put("control", Color.decode("#cccccc")); UIManager.put("info", Color.decode("#ff9900")); // UIManager.put("nimbusAlertYellow", Color.decode("#ff0000")); // UIManager.put("nimbusBase", Color.decode("#4e5a66")); // UIManager.put("nimbusDisabledText", Color.decode("#9900ff")); UIManager.put("nimbusFocus", Color.decode("#ff9933")); // UIManager.put("nimbusGreen", new Color(130, 133, 37)); // UIManager.put("nimbusInfoBlue", Color.decode("#9900ff")); // UIManager.put("nimbusLightBackground", Color.decode("#9900ff")); // UIManager.put("nimbusOrange", new Color(191, 98, 4)); // UIManager.put("nimbusRed", new Color(169, 46, 34)); // UIManager.put("nimbusSelectedText", Color.decode("#ff00ff")); UIManager.put("nimbusSelectionBackground", Color.decode("#465059")); // UIManager.put("text", new Color(0, 0, 0)); UIManager.put("nimbusSelection", Color.decode("#465059")); // UIManager.put("Menu.background", Color.decode("#0066ff")); // UIManager.put("Menu[Enabled+Selected].backgroundPainter", Color.BLUE); SwingUtilities.updateComponentTreeUI(comp); return; } catch (Exception e) { e.printStackTrace();//from ww w . j a v a 2 s .c om } } } }
From source file:Main.java
/** * Sets look and feel to Nimbus.//w w w. j a va 2 s. c om * * @return */ public static boolean setNimbusLF() { try { for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(laf.getName())) { UIManager.setLookAndFeel(laf.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. return false; } return true; }
From source file:Main.java
/** * Should be called before initComponents() * * @param lafName//from w w w .j a v a 2 s .co m */ public static void setLaf(String lafName) { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (info.getName().equals(lafName)) { try { UIManager.setLookAndFeel(info.getClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { } break; } } }
From source file:Main.java
/** * Get a list of all look and feels avaliable * /*w w w.j a v a 2 s . c o m*/ * @return */ public static List<String> getAllLookAndFeels() { List<String> lnf = new Vector<>(); for (LookAndFeelInfo l : UIManager.getInstalledLookAndFeels()) { lnf.add(l.getName()); } return lnf; }
From source file:Main.java
/** * Set the look and feel of the application * /* ww w . j a v a 2 s . co m*/ * @param lookAndFeel * @throws ClassNotFoundException * @throws InstantiationException * @throws IllegalAccessException * @throws UnsupportedLookAndFeelException */ public static void setLookAndFeel(String lookAndFeel) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { String className = null; for (LookAndFeelInfo l : UIManager.getInstalledLookAndFeels()) { if (l.getName().equalsIgnoreCase(lookAndFeel)) { className = l.getClassName(); break; } } if (className != null) UIManager.setLookAndFeel(className); }
From source file:Main.java
/** * Creates a sub-menu for changing Look'n'Feel. * @param rootComponent the root component which Look'n'Feel should be changed (child component are processed recursively). * @return a menu item with sub-menu items for each Look'n'Feel * installed in the system with associated actions to change the * Look'n'Feel for the <code>rootComponent</root>. *///from w w w .ja v a 2s .c om public static JMenu getLafMenu(final Component rootComponent) { JMenu jMenu = new JMenu("Look & Feel"); ButtonGroup buttonGroup = new ButtonGroup(); final UIManager.LookAndFeelInfo[] installedLFs = UIManager.getInstalledLookAndFeels(); String currentLF = UIManager.getLookAndFeel().getName(); for (int i = 0; i < installedLFs.length; i++) { JCheckBoxMenuItem jMenuItem = new JCheckBoxMenuItem(installedLFs[i].getName()); jMenu.add(jMenuItem); buttonGroup.add(jMenuItem); jMenuItem.setState(currentLF.equals(installedLFs[i].getName())); class ChangeLF extends AbstractAction { private UIManager.LookAndFeelInfo iLF; public ChangeLF(UIManager.LookAndFeelInfo iLF) { super(iLF.getName()); this.iLF = iLF; } public void actionPerformed(ActionEvent e) { try { UIManager.setLookAndFeel(iLF.getClassName()); SwingUtilities.updateComponentTreeUI(rootComponent); } catch (Exception ex) { System.out.print("Could not set look and feel: " + ex.toString()); } } } jMenuItem.setAction(new ChangeLF(installedLFs[i])); } return jMenu; }
From source file:md.mclama.com.ModManager.java
/** * Launch the application.// ww w. j ava2 s .c o m */ public static void main(String[] args) { try { workDir = new File(ModManager.class.getProtectionDomain().getCodeSource().getLocation().toURI() .getPath().replace("McLauncher.jar", "")); System.out.println("Running McLauncher from " + workDir); } catch (URISyntaxException e1) { workDir = new File(""); e1.printStackTrace(); } // try { // // Get a file channel for the file // boolean FileNotLocked=false; // // // try { // FileWriter file2 = new FileWriter(System.getProperty("java.io.tmpdir") + "/McLauncher.lock"); // file2.write("McLauncher lock"); // file2.close(); // } catch (IOException e) { // FileNotLocked=true; // } // // File file = new File(System.getProperty("java.io.tmpdir") + "/McLauncher.lock"); // // FileChannel channel = new RandomAccessFile(file, "rw").getChannel(); // if(file.renameTo(file)) FileNotLocked=true; // if(FileNotLocked){ // JOptionPane.showMessageDialog(null, "Already running McLauncher, Only one instance allowed at a time\n" // + "Is this wrong? Delete McLauncher.lock in your temp folder"); // System.out.println("Already running McLauncher, Only one instance allowed at a time"); // System.exit(0); // } // lock = channel.lock(); // // try { // lock = channel.tryLock(); // } catch (OverlappingFileLockException e) { // } // channel.close(); // } catch (Exception e) { // } //Not added because i do not want to lock people out from using McLauncher if somehow this fails. // if(new File(System.getProperty("java.io.tmpdir") + "/McLauncher.lock").exists()){ // System.exit(0);//close this instance if McLauncher is already running. // } // try { // FileWriter file = new FileWriter(System.getProperty("java.io.tmpdir") + "/McLauncher.lock"); // file.write("McLauncher one instance lock"); // file.close(); // } catch (IOException e) { // System.out.println("Severe, failed to create temp lock file"); // } EventQueue.invokeLater(new Runnable() { public void run() { try { con = new Console(); con.setVisible(false); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - con.getWidth()) / 2); int y = (int) ((dimension.getHeight() - con.getHeight()) / 2); con.setLocation(x, y); } catch (Exception e) { e.printStackTrace(); } } }); EventQueue.invokeLater(new Runnable() { @Override public void run() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } ModManager frame = new ModManager(); frame.setResizable(false); frame.setVisible(true); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2); int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:Main.java
public Main() { super(BoxLayout.Y_AXIS); try {//w w w . j a v a 2 s. co m for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); System.out.println("set"); break; } } } catch (Exception e) { e.printStackTrace(); } Object o = UIManager.get("TextArea[Enabled+NotInScrollPane].borderPainter"); UIDefaults paneDefaults = new UIDefaults(); paneDefaults.put("TextPane.borderPainter", o); JTextPane pane = new JTextPane(); pane.setMargin(new Insets(10, 10, 10, 10)); pane.putClientProperty("Nimbus.Overrides", paneDefaults); pane.putClientProperty("Nimbus.Overrides.InheritDefaults", false); pane.setText("this \nis \na \ntest\n"); add(pane); }