public static void initializeLookAndFeel() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception exception) { } }
public static void main(String s[]) { // Trying to set Nimbus look and feel try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ex) { Logger.getLogger(TableExample.class.getName()).log(Level.SEVERE, "Failed to apply Nimbus look and feel", ex); } new TableExample(); }
public static boolean setLookAndFeel(String classname, String name) { if((classname==null||classname.isEmpty())&&(name==null||name.isEmpty())) return false; try { UIManager.setLookAndFeel(classname); usingNimbusLookAndFeel = UIManager.getLookAndFeel().getName().equals("Nimbus"); return true; } catch(Exception e_a) { try { for(LookAndFeelInfo look_and_feel:UIManager.getInstalledLookAndFeels()) if(name.equals(look_and_feel.getName())) { UIManager.setLookAndFeel(look_and_feel.getClassName()); usingNimbusLookAndFeel = UIManager.getLookAndFeel().getName().equals("Nimbus"); return true; } } catch(Exception e_b) {} } return false; }
public static void main(String[] args) { if (args.length != 5) { System.err.println("Needs database parameters eg. ..."); System.err.println( "java TableExample2 \"jdbc:derby://localhost:1527/sample\" " + "org.apache.derby.jdbc.ClientDriver app app " + "\"select * from app.customer\""); return; } // Trying to set Nimbus look and feel try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ex) { Logger.getLogger(TableExample2.class.getName()).log(Level.SEVERE, "Failed to apply Nimbus look and feel", ex); } new TableExample2(args[0], args[1], args[2], args[3], args[4]); }
public static void main(String[] args) { // Trying to set Nimbus look and feel try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ex) { Logger.getLogger(TableExample4.class.getName()).log(Level.SEVERE, "Failed to apply Nimbus look and feel", ex); } new TableExample4(); }
private static void runTest() { try { LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); for (LookAndFeelInfo info : lafInfo) { UIManager.setLookAndFeel(info.getClassName()); for (Locale locale : LOCALES) { for (String key : MNEMONIC_KEYS) { int mnemonic = SwingUtilities2.getUIDefaultsInt(key, locale); if (mnemonic != 0) { throw new RuntimeException("No mnemonic expected (" + mnemonic + ") " + "for '" + key + "' " + "in locale '" + locale + "' " + "in Look-and-Feel '" + UIManager.getLookAndFeel().getClass().getName() + "'"); } } } } System.out.println("Test passed"); } catch (Exception e) { exception = e; } }
public static void main(final String[] args) throws Exception { try { createGUI(); for (final LookAndFeelInfo laf : getInstalledLookAndFeels()) { final String name = laf.getName(); if (name.contains("OS X") || name.contains("Metal")) { SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); SwingUtilities.invokeAndWait(() -> { for (int i = 0; i < 4000; ++i) { SwingUtilities.updateComponentTreeUI(frame); } }); } } } finally { if (frame != null) { EventQueue.invokeAndWait(() -> frame.dispose()); } } }
public static void main(String[] args) throws Exception { Test7024235 test = new Test7024235(); for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { UIManager.setLookAndFeel(info.getClassName()); test.test(); try { ExtendedRobot robot = new ExtendedRobot(); robot.waitForIdle(1000); }catch(Exception ex) { ex.printStackTrace(); throw new Error("Unexpected Failure"); } test.test(); } }
public static void main(final String[] args) throws Exception { try { createGUI(); for (final LookAndFeelInfo laf : getInstalledLookAndFeels()) { final String name = laf.getName(); if (name.contains("OS X") || name.contains("Metal")) { SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); SwingUtilities.invokeAndWait(() -> { for (int i = 0; i < 4000; ++i) { SwingUtilities.updateComponentTreeUI(frame); } }); } } } finally { EventQueue.invokeAndWait(() -> frame.dispose()); } }
public static void main(String[] args) { // Try to use the "Nimbus" Look and Feel for Java. This is purely aesthetic. try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If the Nimbus styling is not available, we fall back to normal styling } JFrame frame = new JFrame("Twitch Chat Analytics"); frame.setContentPane(new AnalyticsGUI(frame).analyticsPanel); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.pack(); frame.setVisible(true); }
/** * Sets the Look And Feel specified by its name. * * <p> * This method does not log in case of errors, so can be called before the logger is initialized. * </p> * * @param lafName name of the Look And Feel to be set * @return the exception if any was thrown while setting the specified Look and Feel */ public static Exception setLaf( final String lafName ) { final Holder< Exception > exception = new Holder< >(); runInEDT( new Runnable() { @Override public void run() { for ( final LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels() ) if ( lafName.equals( lookAndFeelInfo.getName() ) ) { try { UIManager.setLookAndFeel( lookAndFeelInfo.getClassName() ); } catch ( final Exception e ) { exception.value = e; } break; } } } ); return exception.value; }
protected void updateLookAndFeels() { clearButtons(); LookAndFeel currentLookAndFeel = UIManager.getLookAndFeel(); String current = currentLookAndFeel == null ? "" : currentLookAndFeel.getName(); LookAndFeelInfo[] infoArray = UIManager.getInstalledLookAndFeels(); if (infoArray == null || infoArray.length == 0) { return; } for (LookAndFeelInfo info : infoArray) { JRadioButtonMenuItem button = new JRadioButtonMenuItem(info.getName()); button.setActionCommand(info.getClassName()); if (info.getName().equals(current)) button.setSelected(true); addButton(button); } }
protected JMenu createLookAndFeelMenu() { JMenu menu = new LuckMenu(); menu.setOpaque(true); // menu.setBackground(Color.white); menu.setName("lookAndFeel"); // Look for toolkit look and feels first UIManager.LookAndFeelInfo lookAndFeelInfos[] = UIManager.getInstalledLookAndFeels(); lookAndFeel = UIManager.getLookAndFeel().getClass().getName(); lookAndFeelRadioGroup = new ButtonGroup(); for(UIManager.LookAndFeelInfo lafInfo: lookAndFeelInfos) { menu.add(createLookAndFeelItem(lafInfo.getName(), lafInfo.getClassName())); } // Now load any look and feels defined externally as service via java.util.ServiceLoader LOOK_AND_FEEL_LOADER.iterator(); for (LookAndFeel laf : LOOK_AND_FEEL_LOADER) { menu.add(createLookAndFeelItem(laf.getName(), laf.getClass().getName())); } return menu; }
/** * we only want to try and load the Nimbus look and feel if it is not * for the MAC operating system. */ private void loadLookAndFeel() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch(Exception e) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { // we don't care. Cause this should always work. } } }
public void createLAF() { int num = 0; LookAndFeelInfo lafs[] = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lafs.length; i++) { lafTitle.put(i, lafs[i].getName()); } lafTitle.put(lafs.length + 0, "Nimrod"); lafTitle.put(lafs.length + 1, "Nimrod - Burdeos"); lafTitle.put(lafs.length + 2, "Nimrod - DarkGrey"); lafTitle.put(lafs.length + 3, "Nimrod - DarkTabaco"); lafTitle.put(lafs.length + 4, "Nimrod - LightTabaco"); lafTitle.put(lafs.length + 5, "Nimrod - Night"); lafTitle.put(lafs.length + 6, "Nimrod - Snow"); lafOptions = new JComboBox(lafTitle.values().toArray(new String[0])); }
/** * Sets look and feel of the application. * @param name * Name of the lookandfeel * @throws UnsupportedLookAndFeelException * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException */ protected void setLookAndFeel(final String name) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { boolean lafFound = false; for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (name.equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); lafFound = true; break; } } if (!lafFound) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } }
@BeforeClass public static void beforeClass() { // This test will not work in a headless configuration. // need to check before trying to install GTK (any LAF?) if (GraphicsEnvironment.isHeadless()) { LOG.fine("cannot run ui test - headless environment"); return; } LookAndFeelInfo info = new LookAndFeelInfo("GTK plain", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); try { UIManager.installLookAndFeel(info); InteractiveTestCase.setLookAndFeel("GTK"); hasGTK = true; // force loading of addons new JXTable(); new JXList(); } catch (Exception e) { // nothing to do - tests will be ignored; } }
private static void setLookAndFeel() { try { for(LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch(UnsupportedLookAndFeelException | IllegalAccessException | InstantiationException | ClassNotFoundException e) { // Nothing: We revert to the default LAF } }
public static void main(String[] args) { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. } Bank aBank = new Bank(); LogIn login = new LogIn(aBank); ATM atm1 = new ATM(aBank); // aBank.addAccount(new Account("����","b00001","A10546","458712", // new BankAccount("123456",15000,5000))); // aBank.addAccount(new Account("�p�E","b00002","A12608","453354", // new BankAccount("231897",13534,1200))); LogInFrame loginFrame = new LogInFrame(login, atm1); }
/** * Tries to set the specified Look and Feel. * @param name name of the look and feel to be loaded * @return true if the LAF was set successfully, false otherwise */ public static boolean setLAF( final String lafName ) { for ( final LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels() ) if ( lookAndFeelInfo.getName().equals( lafName ) ) try { UIManager.setLookAndFeel( lookAndFeelInfo.getClassName() ); return true; } catch ( final Exception e ) { System.err.println( "Failed to set " + lookAndFeelInfo.getName() + " look and feel!" ); e.printStackTrace( System.err ); return false; } System.err.println( lafName + " look and feel was not found!" ); return false; }