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:LocationSensitiveDemo.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); increaseFont("Tree.font"); increaseFont("Label.font"); increaseFont("ComboBox.font"); increaseFont("List.font"); } catch (Exception e) { }//from www. j a va 2 s . c om // Turn off metal's use of bold fonts UIManager.put("swing.boldMetal", Boolean.FALSE); createAndShowGUI(); } }); }
From source file:EditorDropTarget3.java
public static void main(String[] args) { try {// w w w . java 2 s . c o m UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } final JFrame f = new JFrame("JEditor Pane Drop Target Example 3"); final JEditorPane pane = new JEditorPane(); // Add a drop target to the JEditorPane EditorDropTarget3 target = new EditorDropTarget3(pane); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); JPanel panel = new JPanel(); final JCheckBox editable = new JCheckBox("Editable"); editable.setSelected(true); panel.add(editable); editable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEditable(editable.isSelected()); } }); final JCheckBox enabled = new JCheckBox("Enabled"); enabled.setSelected(true); panel.add(enabled); enabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEnabled(enabled.isSelected()); } }); f.getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER); f.getContentPane().add(panel, BorderLayout.SOUTH); f.setSize(500, 400); f.setVisible(true); }
From source file:net.erdfelt.android.sdkfido.ui.utils.UIUtils.java
public static void setJavaLookAndFeel() { try {//from ww w. j ava2s. c o m UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { log.warn("Unable to set Java Look and Feel.", e); } JFrame.setDefaultLookAndFeelDecorated(true); }
From source file:md.mclama.com.ModManager.java
/** * Launch the application./*from w w w . j ava 2 s. co 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 {//from w w w .ja va 2s.com 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); }
From source file:edu.ku.brc.specify.config.init.secwiz.SpecifyDBSecurityWizardFrame.java
/** * @param args/*from w w w.j a va2s .co m*/ */ public static void main(String[] args) { // Set App Name, MUST be done very first thing! UIRegistry.setAppName("Specify"); //$NON-NLS-1$ try { ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$ } catch (MissingResourceException ex) { Locale.setDefault(Locale.ENGLISH); UIRegistry.setResourceLocale(Locale.ENGLISH); } try { if (!System.getProperty("os.name").equals("Mac OS X")) { UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new DesertBlue()); } } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSecurityWizard.class, e); e.printStackTrace(); } AppBase.processArgs(args); AppBase.setupTeeForStdErrStdOut(true, false); System.setProperty("appdatadir", ".."); SwingUtilities.invokeLater(new Runnable() { public void run() { // Then set this IconManager.setApplicationClass(Specify.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$ // Load Local Prefs AppPreferences localPrefs = AppPreferences.getLocalPrefs(); //try { //System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+(new File(UIRegistry.getAppDataDir()).getCanonicalPath())+"]"); //} catch (IOException ex) {} localPrefs.setDirPath(UIRegistry.getAppDataDir()); // Check to see if we should check for a new version String VERSION_CHECK = "version_check.auto"; if (localPrefs.getBoolean(VERSION_CHECK, null) == null) { localPrefs.putBoolean(VERSION_CHECK, true); } String EXTRA_CHECK = "extra.check"; if (localPrefs.getBoolean(EXTRA_CHECK, null) == null) { localPrefs.putBoolean(EXTRA_CHECK, true); } if (UIHelper.isLinux()) { Specify.checkForSpecifyAppsRunning(); } if (UIRegistry.isEmbedded()) { checkForMySQLProcesses(); } Specify.setUpSystemProperties(); final SpecifyDBSecurityWizardFrame wizardFrame = new SpecifyDBSecurityWizardFrame(); if (localPrefs.getBoolean(VERSION_CHECK, true) && localPrefs.getBoolean(EXTRA_CHECK, true)) { try { com.install4j.api.launcher.SplashScreen.hide(); ApplicationLauncher.Callback callback = new ApplicationLauncher.Callback() { public void exited(int exitValue) { UIHelper.centerAndShow(wizardFrame); } public void prepareShutdown() { } }; ApplicationLauncher.launchApplication("100", null, true, callback); } catch (Exception ex) { UIHelper.centerAndShow(wizardFrame); } } else { UIHelper.centerAndShow(wizardFrame); } } }); }
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>. */// w w w .j a va 2 s . 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:MyLookAndFeel.java
public Main() throws Exception { UIManager.setLookAndFeel("MyLookAndFeel"); setLayout(new FlowLayout()); JButton b = new JButton(); b.setText("<html>A<br> B</html>"); b.setToolTipText("<html>C<br>D<br>E</html>"); add(b);/*from w w w . ja va2 s . com*/ JLabel l = new JLabel("Z"); l.setToolTipText("zzzzz..."); add(l); }
From source file:br.usp.poli.lta.cereda.macro.util.DisplayUtils.java
/** * Inicializa a classe de exibio, definindo o tema das janelas. *//*from w w w .ja va 2 s . c om*/ public static void init() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception exception) { logger.error("Ocorreu um erro: {}", exception.getMessage()); } }
From source file:EditorDropTarget4.java
public static void main(String[] args) { try {/*from ww w. java2 s. c om*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } final JFrame f = new JFrame("JEditor Pane Drop Target Example 4"); // Create an editor with autoscrolling support final JEditorPane pane = new AutoScrollingEditorPane(); // Add a drop target to the JEditorPane EditorDropTarget4 target = new EditorDropTarget4(pane); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); JPanel panel = new JPanel(); final JCheckBox editable = new JCheckBox("Editable"); editable.setSelected(true); panel.add(editable); editable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEditable(editable.isSelected()); } }); final JCheckBox enabled = new JCheckBox("Enabled"); enabled.setSelected(true); panel.add(enabled); enabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pane.setEnabled(enabled.isSelected()); } }); f.getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER); f.getContentPane().add(panel, BorderLayout.SOUTH); f.setSize(500, 400); f.setVisible(true); }