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:de.tor.tribes.ui.algo.SettingsPanel.java
public static void main(String[] args) { try {/*from w ww . j ava 2 s. c om*/ // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (Exception e) { } JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final SettingsPanel sp = new SettingsPanel(null); f.add(sp); f.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosing(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); f.pack(); f.setVisible(true); }
From source file:com.xmage.launcher.XMageLauncher.java
public static void main(String[] args) { try {//from w ww .j a va 2s .co m UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); XMageLauncher gui = new XMageLauncher(); SwingUtilities.invokeLater(gui); } catch (ClassNotFoundException ex) { logger.error("Error: ", ex); } catch (InstantiationException ex) { logger.error("Error: ", ex); } catch (IllegalAccessException ex) { logger.error("Error: ", ex); } catch (UnsupportedLookAndFeelException ex) { logger.error("Error: ", ex); } }
From source file:net.chaosserver.timelord.swingui.Timelord.java
/** * Constructs the new timelord object./* w w w . ja v a2 s . c o m*/ */ public Timelord() { // Set the UI to the system look and feel so the application // appears more native. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { if (log.isWarnEnabled()) { log.warn("Failed to set look and feel", e); } } }
From source file:Converter.java
private static void initLookAndFeel() { String lookAndFeel = null;// w w w . j ava 2s . com if (LOOKANDFEEL != null) { if (LOOKANDFEEL.equals("Metal")) { lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName(); } else if (LOOKANDFEEL.equals("System")) { lookAndFeel = UIManager.getSystemLookAndFeelClassName(); } else if (LOOKANDFEEL.equals("Motif")) { lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; } else if (LOOKANDFEEL.equals("GTK+")) { // new in 1.4.2 lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; } else { System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL); lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName(); } try { UIManager.setLookAndFeel(lookAndFeel); } catch (ClassNotFoundException e) { System.err.println("Couldn't find class for specified look and feel:" + lookAndFeel); System.err.println("Did you include the L&F library in the class path?"); System.err.println("Using the default look and feel."); } catch (UnsupportedLookAndFeelException e) { System.err.println("Can't use the specified look and feel (" + lookAndFeel + ") on this platform."); System.err.println("Using the default look and feel."); } catch (Exception e) { System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason."); System.err.println("Using the default look and feel."); e.printStackTrace(); } } }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
public MainController() { iliasProperties = readProperties();// ww w . j a va 2 s .c om if (iliasProperties.getLookAndFeel() == null || iliasProperties.getLookAndFeel().trim().isEmpty()) { iliasProperties.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } try { UIManager.setLookAndFeel(iliasProperties.getLookAndFeel()); } catch (Exception e1) { e1.printStackTrace(); } fileObjectTableModel = new FileObjectTableModel(); mainFrame = new MainFrame(this, initMenuBar()); // initTableFiles(); handleFirstStart(); mainFrame.getFieldLogin().setText(iliasProperties.getUserName()); updateTitleCaption(); mainFrame.getCheckboxNotDownload().setSelected(!iliasProperties.isAllowDownload()); if (!mainFrame.getFieldLogin().getText().trim().isEmpty()) { mainFrame.getFieldPassword().requestFocus(); } syncService = new SyncService(this, this, new ObjectDoInterfaceX<Void, IliasProperties>() {//IliasProperties Callback @Override public IliasProperties doSomething(Void object) { iliasProperties.setUserName(mainFrame.getFieldLogin().getText()); iliasProperties.setAllowDownload(!mainFrame.getCheckboxNotDownload().isSelected()); saveProperties(iliasProperties); return iliasProperties; } }, new ObjectDoInterfaceX<Void, String>() {//Password Callback @Override public String doSomething(Void object) { return new String(mainFrame.getFieldPassword().getPassword()); } }, new ObjectDoInterfaceX<Throwable, Void>() { @Override public Void doSomething(Throwable e) { showError("Fehler bei der Dateisynchronisierung: " + e.getMessage(), e); return null; } }); mainFrame.addWindowListener(new WindowAdapter() { @Override public void windowIconified(WindowEvent e) { minimizeToTray(); } @Override public void windowClosing(WindowEvent e) { try { syncService.logoutIfLoggedIn(); } catch (Exception ex) { System.exit(0); } } }); startOrStopAutoSync(); }
From source file:ch.admin.hermes.etl.load.HermesETLApplication.java
/** * CommandLine parse und fehlende Argumente verlangen * @param args Args/*from w w w . j av a2 s. co m*/ * @throws ParseException */ private static void parseCommandLine(String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // HACK um UTF-8 CharSet fuer alle Dateien zu setzen (http://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding) System.setProperty("file.encoding", "UTF-8"); Field charset = Charset.class.getDeclaredField("defaultCharset"); charset.setAccessible(true); charset.set(null, null); // commandline Options - FremdsystemSite, Username und Password Options options = new Options(); options.addOption("s", true, "Zielsystem - URL"); options.addOption("u", true, "Zielsystem - Username"); options.addOption("p", true, "Zielsystem - Password"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); site = cmd.getOptionValue("s"); user = cmd.getOptionValue("u"); passwd = cmd.getOptionValue("p"); // restliche Argumente pruefen - sonst usage ausgeben String[] others = cmd.getArgs(); if (others.length >= 1 && (others[0].endsWith(".js") || others[0].endsWith(".ftl"))) script = others[0]; if (others.length >= 2 && others[1].endsWith(".xml")) model = others[1]; // Dialog mit allen Werten zusammenstellen JComboBox<String> scenarios = new JComboBox<String>(crawler.getScenarios()); JTextField tsite = new JTextField(45); tsite.setText(site); JTextField tuser = new JTextField(16); tuser.setText(user); JPasswordField tpasswd = new JPasswordField(16); tpasswd.setText(passwd); final JTextField tscript = new JTextField(45); tscript.setText(script); final JTextField tmodel = new JTextField(45); tmodel.setText(model); JPanel myPanel = new JPanel(new GridLayout(6, 2)); myPanel.add(new JLabel("Szenario (von http://www.hermes.admin.ch):")); myPanel.add(scenarios); myPanel.add(new JLabel("XML Model:")); myPanel.add(tmodel); JPanel pmodel = new JPanel(); pmodel.add(tmodel); JButton bmodel = new JButton("..."); pmodel.add(bmodel); bmodel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { model = getFile("Szenario XML Model", new String[] { "XML Model" }, new String[] { ".xml" }); if (model != null) tmodel.setText(model); } }); myPanel.add(pmodel); scenarios.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { try { Object o = e.getItem(); tmodel.setText(crawler.getModelURL(o.toString())); scenario = o.toString(); } catch (Exception e1) { } } }); // Script myPanel.add(new JLabel("Umwandlungs-Script:")); JPanel pscript = new JPanel(); pscript.add(tscript); JButton bscript = new JButton("..."); pscript.add(bscript); myPanel.add(pscript); bscript.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { script = getFile("JavaScript/Freemarker Umwandlungs-Script", new String[] { "JavaScript", "Freemarker" }, new String[] { ".js", ".ftl" }); if (script != null) tscript.setText(script); } }); // Zielsystem Angaben myPanel.add(new JLabel("Zielsystem URL:")); myPanel.add(tsite); myPanel.add(new JLabel("Zielsystem Benutzer:")); myPanel.add(tuser); myPanel.add(new JLabel("Zielsystem Password:")); myPanel.add(tpasswd); // Trick um Feld scenario und model zu setzen. if (scenarios.getItemCount() >= 8) scenarios.setSelectedIndex(8); // Dialog int result = JOptionPane.showConfirmDialog(null, myPanel, "HERMES 5 XML Model nach Fremdsystem/Format", JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { site = tsite.getText(); user = tuser.getText(); passwd = new String(tpasswd.getPassword()); model = tmodel.getText(); script = tscript.getText(); } else System.exit(1); if (model == null || script == null || script.trim().length() == 0) usage(); if (script.endsWith(".js")) if (site == null || user == null || passwd == null || user.trim().length() == 0 || passwd.trim().length() == 0) usage(); }
From source file:InternalFrameListenerDemo.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == m_newFrame) newFrame();//ww w . j a v a 2 s . c o m else if (e.getSource() == m_eventTimer) { m_ifEventCanvas.render(getCounts()); clearCounts(); } else if (e.getSource() == m_UIBox) { try { m_UIBox.hidePopup(); //BUG WORKAROUND UIManager.setLookAndFeel(m_infos[m_UIBox.getSelectedIndex()].getClassName()); SwingUtilities.updateComponentTreeUI(this); } catch (Exception ex) { System.out.println("Could not load " + m_infos[m_UIBox.getSelectedIndex()].getClassName()); } } }
From source file:com.samczsun.helios.Helios.java
public static void main(String[] args, Shell shell, Splash splashScreen) { System.setSecurityManager(new SecurityManager() { @Override//from ww w. ja v a 2s.c o m public void checkPermission(Permission perm) { } @Override public void checkPermission(Permission perm, Object context) { } @Override public void checkCreateClassLoader() { } @Override public void checkAccess(Thread t) { } @Override public void checkAccess(ThreadGroup g) { } @Override public void checkExit(int status) { if (!getClassContext()[3].getCanonicalName().startsWith("com.samczsun")) { throw new SecurityException(); //Baksmali } } @Override public void checkExec(String cmd) { } @Override public void checkLink(String lib) { } @Override public void checkRead(FileDescriptor fd) { } @Override public void checkRead(String file) { } @Override public void checkRead(String file, Object context) { } @Override public void checkWrite(FileDescriptor fd) { } @Override public void checkWrite(String file) { } @Override public void checkDelete(String file) { } @Override public void checkConnect(String host, int port) { } @Override public void checkConnect(String host, int port, Object context) { } @Override public void checkListen(int port) { } @Override public void checkAccept(String host, int port) { } @Override public void checkMulticast(InetAddress maddr) { } @Override public void checkMulticast(InetAddress maddr, byte ttl) { } @Override public void checkPropertiesAccess() { } @Override public void checkPropertyAccess(String key) { } @Override public boolean checkTopLevelWindow(Object window) { return true; } @Override public void checkPrintJobAccess() { } @Override public void checkSystemClipboardAccess() { } @Override public void checkAwtEventQueueAccess() { } @Override public void checkPackageAccess(String pkg) { } @Override public void checkPackageDefinition(String pkg) { } @Override public void checkSetFactory() { } @Override public void checkMemberAccess(Class<?> clazz, int which) { } @Override public void checkSecurityAccess(String target) { } }); try { if (!System.getProperty("os.name").toLowerCase().contains("linux")) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (Exception exception) { //Not important. No point notifying the user } splashScreen.updateState(BootSequence.LOADING_SETTINGS); Settings.loadSettings(); backgroundTaskGui = new BackgroundTaskGui(); backgroundTaskHandler = new BackgroundTaskHandler(); splashScreen.updateState(BootSequence.LOADING_ADDONS); AddonHandler.registerPreloadedAddons(); for (File file : Constants.ADDONS_DIR.listFiles()) { AddonHandler.getAllHandlers().stream().filter(handler -> handler.accept(file)).findFirst() .ifPresent(handler -> { handler.run(file); }); } splashScreen.updateState(BootSequence.SETTING_UP_GUI); gui = new GUI(shell); Runtime.getRuntime().addShutdownHook(new Thread(() -> { Settings.saveSettings(); getBackgroundTaskHandler().shutdown(); processes.forEach(Process::destroy); })); splashScreen.updateState(BootSequence.COMPLETE); while (!splashScreen.isDisposed()) ; Display.getDefault().syncExec(() -> getGui().getShell().open()); List<File> open = new ArrayList<>(); for (String name : args) { File file = new File(name); if (file.exists()) { open.add(file); } } submitBackgroundTask(() -> { Map<String, LoadedFile> newPath = new HashMap<>(); for (String strFile : Sets.newHashSet(Settings.PATH.get().asString().split(";"))) { File file = new File(strFile); if (file.exists()) { try { LoadedFile loadedFile = new LoadedFile(file); newPath.put(loadedFile.getName(), loadedFile); } catch (IOException e1) { ExceptionHandler.handle(e1); } } } synchronized (Helios.class) { path.clear(); path.putAll(newPath); } }); if (open.size() > 0) { openFiles(open.toArray(new File[open.size()]), true); } }
From source file:DesktopManagerDemo.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == m_newFrame) newFrame();//from w w w.j a va2s. c o m else if (e.getSource() == m_eventTimer) { m_dmEventCanvas.render(m_myDesktopManager.getCounts()); m_myDesktopManager.clearCounts(); } else if (e.getSource() == m_UIBox) { try { m_UIBox.hidePopup(); //BUG WORKAROUND UIManager.setLookAndFeel(m_infos[m_UIBox.getSelectedIndex()].getClassName()); SwingUtilities.updateComponentTreeUI(this); } catch (Exception ex) { System.out.println("Could not load " + m_infos[m_UIBox.getSelectedIndex()].getClassName()); } } }
From source file:ch.descabato.browser.BackupBrowser.java
private static void tryLoadSubstanceLookAndFeel() { if (!StringUtils.isNotBlank(System.getProperty("swing.defaultlaf", ""))) {//NON-NLS try {//from w w w. j a v a 2s . c o m Object lookAndFeel = Class .forName("org.pushingpixels.substance.api.skin.SubstanceModerateLookAndFeel").newInstance(); UIManager.setLookAndFeel((LookAndFeel) lookAndFeel); } catch (UnsupportedLookAndFeelException e) { LOGGER.info("Can't change look and feel: ", e);//NON-NLS } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { LOGGER.info("Didn't find substance look and feel: ", e);//NON-NLS } } else { LOGGER.info("swing.defaultlaf is set, do not switching to Substance LF");//NON-NLS } }