Java Code Examples for javax.swing.UIManager.LookAndFeelInfo

The following examples show how to use javax.swing.UIManager.LookAndFeelInfo. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Cafebabe   Source File: Cafebabe.java    License: GNU General Public License v3.0 7 votes vote down vote up
public static void main(String[] args) throws Exception {
	try {
		folder = new File(System.getProperty("user.home"), ".cafebabe");
		if (!folder.exists()) {
			folder.mkdir();
		}
		for (LookAndFeelInfo lafi : UIManager.getInstalledLookAndFeels()) {
			if (lafi.getName().equals("Nimbus")) {
				UIManager.setLookAndFeel(lafi.getClassName());
				break;
			}
		}
		new Translations(); //load translations
		WebLookAndFeel.install();
		System.setProperty("file.encoding", "UTF-8");
		Field charset = Charset.class.getDeclaredField("defaultCharset");
		charset.setAccessible(true);
		charset.set(null, null);
		Settings.loadSettings();
		WebLookAndFeel.setDecorateFrames(decorated);
		WebLookAndFeel.setDecorateDialogs(decorated);
	} catch (Throwable t) {
		t.printStackTrace();
	}
	new Cafebabe();
	gui.setVisible(true);
}
 
Example 2
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]);
}
 
Example 3
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();
}
 
Example 4
Source Project: jdk8u-dev-jdk   Source File: TableExample.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 5
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]);
}
 
Example 6
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());
    }
}
 
Example 7
Source Project: jdk8u-jdk   Source File: TableExample.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 8
Source Project: jdk8u-jdk   Source File: TableExample.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 9
Source Project: jdk8u-jdk   Source File: TableExample4.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 10
Source Project: jdk8u-jdk   Source File: TableExample2.java    License: GNU General Public License v2.0 6 votes vote down vote up
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]);
}
 
Example 11
Source Project: openjdk-8   Source File: TableExample2.java    License: GNU General Public License v2.0 6 votes vote down vote up
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]);
}
 
Example 12
Source Project: netbeans   Source File: LafPanel.java    License: Apache License 2.0 6 votes vote down vote up
protected boolean store() {
    prefs.putBoolean(WinSysPrefs.MAXIMIZE_NATIVE_LAF, checkMaximizeNativeLaF.isSelected());
    System.setProperty("nb.native.filechooser", checkMaximizeNativeLaF.isSelected() ? "true" : "false"); //NOI18N

    int selLaFIndex = comboLaf.getSelectedIndex();
    if( selLaFIndex != defaultLookAndFeelIndex && !isForcedLaF() ) {
        LookAndFeelInfo li = lafs.get( comboLaf.getSelectedIndex() );
        NbPreferences.root().node( "laf" ).put( "laf", li.getClassName() ); //NOI18N
        if (NO_RESTART_ON_LAF_CHANGE) {
            try {
                UIManager.setLookAndFeel(li.getClassName());
                WindowManager wmgr = Lookup.getDefault().lookup(WindowManager.class);
                wmgr.updateUI();
            } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException ex) {
                askForRestart();
            }
        } else {
            askForRestart();
        }
    }

    return false;
}
 
Example 13
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]);
}
 
Example 14
Source Project: jdk8u_jdk   Source File: bug8080628.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 15
Source Project: scelight   Source File: LGuiUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source Project: slick2d-maven   Source File: Hiero.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
			for (int i = 0, n = lookAndFeels.length; i < n; i++) {
				if ("Nimbus".equals(lookAndFeels[i].getName())) {
					try {
						UIManager.setLookAndFeel(lookAndFeels[i].getClassName());
					} catch (Exception ignored) {
					}
					break;
				}
			}
			try {
				new Hiero();
			} catch (SlickException ex) {
				throw new RuntimeException(ex);
			}
		}
	});
}
 
Example 17
Source Project: openjdk-jdk8u   Source File: TableExample4.java    License: GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 18
public void run() {
  int indent = 0;
  try {
    final String lnfName = WorkspaceSettings.getInstance().getLNF();
    if ( !StringUtils.isEmpty( lnfName ) ) {
      final LookAndFeelInfo[] lnfs = UIManager.getInstalledLookAndFeels();
      for ( final LookAndFeelInfo lnf : lnfs ) {
        if ( lnf.getName().equals( lnfName ) ) {
          UIManager.setLookAndFeel( lnf.getClassName() );
          return;
        }
      }
    }

    UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
    indent = 5; //PRD-4583
  } catch ( Throwable t ) {
    UncaughtExceptionsModel.getInstance().addException( t );
  }

  final UIDefaults uiDefaults = UIManager.getDefaults();
  uiDefaults.put( "Table.gridColor", uiDefaults.get( "Panel.background" ) );// NON-NLS
  uiDefaults.put( "Tree.leftChildIndent", indent );//PRD-4419
}
 
Example 19
Source Project: openjdk-jdk8u   Source File: Test6981576.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    if (this.infos == null) {
        this.infos = UIManager.getInstalledLookAndFeels();
        Thread.currentThread().setUncaughtExceptionHandler(this);
        JPanel panel = new JPanel();
        panel.setBorder(this);
        this.frame = new JFrame(getClass().getSimpleName());
        this.frame.add(panel);
        this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.frame.setVisible(true);
    }
    if (this.index == this.infos.length) {
        this.frame.dispose();
    }
    else {
        LookAndFeelInfo info = this.infos[this.index % this.infos.length];
        try {
            UIManager.setLookAndFeel(info.getClassName());
        }
        catch (Exception exception) {
            System.err.println("could not change look and feel");
        }
        SwingUtilities.updateComponentTreeUI(this.frame);
        this.frame.pack();
        this.frame.setLocationRelativeTo(null);
        this.index++;
        SwingUtilities.invokeLater(this);
    }
}
 
Example 20
Source Project: FlatLaf   Source File: LookAndFeelsComboBox.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings( "unchecked" )
public LookAndFeelsComboBox() {
	setRenderer( new BasicComboBoxRenderer() {
		@Override
		@SuppressWarnings( "rawtypes" )
		public Component getListCellRendererComponent( JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus )
		{
			value = (value != null)
				? ((LookAndFeelInfo)value).getName()
				: UIManager.getLookAndFeel().getName();
			return super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
		}
	} );
}
 
Example 21
Source Project: jdk8u_jdk   Source File: UITest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static boolean hasLAF(String name, LookAndFeelInfo[] lafInfo) {

        for (int counter = 0; counter < lafInfo.length; counter++) {
            if (lafInfo[counter].getName().toLowerCase().indexOf(name) != -1) {
                return true;
            }
        }
        return false;
    }
 
Example 22
Source Project: FlatLaf   Source File: LookAndFeelsComboBox.java    License: Apache License 2.0 5 votes vote down vote up
public int getIndexOfLookAndFeel( String className ) {
	ComboBoxModel<LookAndFeelInfo> model = getModel();
	int size = model.getSize();
	for( int i = 0; i < size; i++ ) {
		if( className.equals( model.getElementAt( i ).getClassName() ) )
			return i;
	}
	return -1;
}
 
Example 23
Source Project: Ardulink-2   Source File: LAFUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void setLookAndFeel(String lafName) throws ClassNotFoundException,
		InstantiationException, IllegalAccessException,
		UnsupportedLookAndFeelException {
	for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
		if (lafName.equals(laf.getName())) {
			UIManager.setLookAndFeel(laf.getClassName());
		}
	}
}
 
Example 24
Source Project: jdk8u-jdk   Source File: bug8002077.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            runTest();
            break;
        }
    }
}
 
Example 25
Source Project: openjdk-jdk9   Source File: bug8081411.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean checkAndSetNimbusLookAndFeel() {
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                return true;
            }
        }
        return false;
    } catch (Exception ignore) {
        return false;
    }
}
 
Example 26
Source Project: openjdk-8-source   Source File: UITest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static boolean hasLAF(String name, LookAndFeelInfo[] lafInfo) {

        for (int counter = 0; counter < lafInfo.length; counter++) {
            if (lafInfo[counter].getName().toLowerCase().indexOf(name) != -1) {
                return true;
            }
        }
        return false;
    }
 
Example 27
Source Project: dragonwell8_jdk   Source File: bug8002077.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            UIManager.put("FileChooser.openButtonMnemonic", KeyEvent.VK_O);
            UIManager.put("FileChooser.saveButtonMnemonic", KeyEvent.VK_S);
            runTest();
            break;
        }
    }
}
 
Example 28
Source Project: zxpoly   Source File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void main(final String[] args) {
  if (args.length > 0) {
    switch (args[0]) {
      case "sliceImage": {
        System.exit(new SliceImageCmd().process(Arrays.copyOfRange(args, 1, args.length)));
      }
      break;
      default: {
        System.err.println("Unexpected command : " + args[0]);
        System.exit(1);
      }
    }
  }

  java.util.Locale.setDefault(Locale.ROOT);

  try {
    for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
      if ("Nimbus".equals(info.getName())) {
        UIManager.setLookAndFeel(info.getClassName());
        break;
      }
    }
  } catch (Exception e) {
    e.printStackTrace();
  }

  SwingUtilities.invokeLater(() -> {
    final JFrame frame = new MainFrame();
    frame.setVisible(true);
  });

}
 
Example 29
Source Project: dragonwell8_jdk   Source File: Test6981576.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    if (this.infos == null) {
        this.infos = UIManager.getInstalledLookAndFeels();
        Thread.currentThread().setUncaughtExceptionHandler(this);
        JPanel panel = new JPanel();
        panel.setBorder(this);
        this.frame = new JFrame(getClass().getSimpleName());
        this.frame.add(panel);
        this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.frame.setVisible(true);
    }
    if (this.index == this.infos.length) {
        this.frame.dispose();
    }
    else {
        LookAndFeelInfo info = this.infos[this.index % this.infos.length];
        try {
            UIManager.setLookAndFeel(info.getClassName());
        }
        catch (Exception exception) {
            System.err.println("could not change look and feel");
        }
        SwingUtilities.updateComponentTreeUI(this.frame);
        this.frame.pack();
        this.frame.setLocationRelativeTo(null);
        this.index++;
        SwingUtilities.invokeLater(this);
    }
}
 
Example 30
Source Project: openjdk-jdk9   Source File: Test7163696.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void test() throws Exception {
    Robot robot = new Robot();
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        UIManager.setLookAndFeel(info.getClassName());

        SwingUtilities.invokeAndWait(this);
        robot.waitForIdle(); // after creation
        Thread.sleep(1000);

        Point point = this.bar.getLocation();
        SwingUtilities.convertPointToScreen(point, this.bar);
        point.x += this.bar.getWidth() >> 2;
        point.y += this.bar.getHeight() >> 1;
        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

        robot.waitForIdle(); // before validation
        Thread.sleep(1000);
        SwingUtilities.invokeAndWait(this);

        if (this.bar != null) {
            this.bar = null; // allows to reuse the instance
            if (AUTO) { // error reporting only for automatic testing
                throw new Error("TEST FAILED");
            }
        }
    }
}