List of usage examples for javax.swing UIManager getSystemLookAndFeelClassName
public static String getSystemLookAndFeelClassName()
LookAndFeel
class that implements the native system look and feel if there is one, otherwise the name of the default cross platform LookAndFeel
class. From source file:ch.admin.hermes.etl.load.HermesETLApplication.java
/** * CommandLine parse und fehlende Argumente verlangen * @param args Args// w w w. ja v a 2s . c o 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:net.pms.newgui.LooksFrame.java
public static void initializeLookAndFeel() { synchronized (lookAndFeelInitializedLock) { if (lookAndFeelInitialized) { return; }/*from w ww. j a v a2 s . c om*/ if (Platform.isWindows()) { try { UIManager.setLookAndFeel(WINDOWS_LNF); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { LOGGER.error("Error while setting Windows look and feel: ", e); } } else if (System.getProperty("nativelook") == null && !Platform.isMac()) { try { UIManager.setLookAndFeel(PLASTICXP_LNF); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { LOGGER.error("Error while setting Plastic XP look and feel: ", e); } } else { try { String systemClassName = UIManager.getSystemLookAndFeelClassName(); // Workaround for Gnome try { String gtkLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; Class.forName(gtkLAF); if (systemClassName.equals("javax.swing.plaf.metal.MetalLookAndFeel")) { systemClassName = gtkLAF; } } catch (ClassNotFoundException ce) { LOGGER.error("Error loading GTK look and feel: ", ce); } LOGGER.trace("Choosing Java look and feel: " + systemClassName); UIManager.setLookAndFeel(systemClassName); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { try { UIManager.setLookAndFeel(PLASTICXP_LNF); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { LOGGER.error("Error while setting Plastic XP look and feel: ", e); } LOGGER.error("Error while setting native look and feel: ", e1); } } if (isParticularLaFSet(UIManager.getLookAndFeel(), PLASTICXP_LNF)) { PlasticLookAndFeel.setPlasticTheme(PlasticLookAndFeel.createMyDefaultTheme()); PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_DEFAULT_VALUE); PlasticLookAndFeel.setHighContrastFocusColorsEnabled(false); } else if (isParticularLaFSet(UIManager.getLookAndFeel(), METAL_LNF)) { MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); } // Work around caching in MetalRadioButtonUI JRadioButton radio = new JRadioButton(); radio.getUI().uninstallUI(radio); JCheckBox checkBox = new JCheckBox(); checkBox.getUI().uninstallUI(checkBox); // Workaround for JDK-8179014: JFileChooser with Windows look and feel crashes on win 10 // https://bugs.openjdk.java.net/browse/JDK-8179014 if (isParticularLaFSet(UIManager.getLookAndFeel(), WINDOWS_LNF)) { UIManager.put("FileChooser.useSystemExtensionHiding", false); } lookAndFeelInitialized = true; } }
From source file:com.samczsun.helios.Helios.java
public static void main(String[] args, Shell shell, Splash splashScreen) { System.setSecurityManager(new SecurityManager() { @Override//from w w w . j av a 2 s . c om 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:io.gameover.utilities.pixeleditor.Pixelizer.java
private void applyLookAndFeel() { try {/*from ww w.j a v a2 s . c om*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } }
From source file:facturas.PDF.CommandLineOptions.java
/** * Parse the command line arguments./*w w w. j a v a 2 s.co m*/ * * @param args * the command line arguments. * @throws FOPException * for general errors * @throws FileNotFoundException * if an input file wasn't found * @throws IOException * if the the configuration file could not be loaded */ public void parse(String[] args) throws FOPException, IOException { boolean optionsParsed = true; try { optionsParsed = parseOptions(args); if (optionsParsed) { if (showConfiguration == Boolean.TRUE) { dumpConfiguration(); } checkSettings(); setUserConfig(); // Factory config is set up, now we can create the user agent foUserAgent = factory.newFOUserAgent(); foUserAgent.getRendererOptions().putAll(renderingOptions); if (targetResolution != 0) { foUserAgent.setTargetResolution(targetResolution); } addXSLTParameter("fop-output-format", getOutputFormat()); addXSLTParameter("fop-version", Version.getVersion()); } } catch (FOPException e) { printUsage(); throw e; } catch (java.io.FileNotFoundException e) { printUsage(); throw e; } inputHandler = createInputHandler(); if (MimeConstants.MIME_FOP_AWT_PREVIEW.equals(outputmode)) { // set the system look&feel for the preview dialog try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.err.println("Couldn't set system look & feel!"); } AWTRenderer renderer = new AWTRenderer(true); renderer.setRenderable(inputHandler); // set before user agent! renderer.setUserAgent(foUserAgent); foUserAgent.setRendererOverride(renderer); } else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode) && mimicRenderer != null) { // render from FO to Intermediate Format Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer(foUserAgent, mimicRenderer); XMLRenderer xmlRenderer = new XMLRenderer(); xmlRenderer.setUserAgent(foUserAgent); // Tell the XMLRenderer to mimic the target renderer xmlRenderer.mimicRenderer(targetRenderer); // Make sure the prepared XMLRenderer is used foUserAgent.setRendererOverride(xmlRenderer); } }
From source file:llc.rockford.webcast.EC2Driver.java
private void initLookAndFeel() { String lookAndFeel = null;/* w w w . jav a 2s .c o m*/ 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")) { 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); // If L&F = "Metal", set the theme if (LOOKANDFEEL.equals("Metal")) { if (THEME.equals("DefaultMetal")) MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); else if (THEME.equals("Ocean")) MetalLookAndFeel.setCurrentTheme(new OceanTheme()); UIManager.setLookAndFeel(new MetalLookAndFeel()); } } 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:com.brainflow.application.toplevel.Brainflow.java
public void launch() throws Throwable { try {/*from ww w .j a v a 2 s . com*/ String osname = System.getProperty("os.name"); if (osname.toUpperCase().contains("WINDOWS")) { UIManager.setLookAndFeel(new WindowsLookAndFeel()); //UIManager.setLookAndFeel(new com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel()); //LookAndFeelFactory.NimbusInitializer init = new LookAndFeelFactory.NimbusInitializer(); //init.initialize(UIManager.getDefaults()); //UIManager.getDefaults(). LookAndFeelFactory.installJideExtension(); //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2003_STYLE); } else if (osname.toUpperCase().contains("LINUX")) { UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); LookAndFeelFactory.installJideExtension(); } } catch (UnsupportedLookAndFeelException e) { log.severe("could not load look and feel"); } //final SplashScreen splash = SplashScreen.getSplashScreen(); //JFrame.setDefaultLookAndFeelDecorated(true); long startTime = System.currentTimeMillis(); brainFrame = new BrainFrame(); statusBar = new StatusBar(); reportTime(startTime, "created brainframe"); brainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); log.info("initializing DisplayManager ..."); DisplayManager.getInstance().createCanvas(); log.info("initializing resources ..."); FutureTask<Boolean> initResources = new FutureTask<Boolean>(new Callable<Boolean>() { public Boolean call() throws Exception { return initializeResources(); } }); threadService.execute(initResources); log.info("loading commands ..."); FutureTask<Boolean> loadCommandsTask = new FutureTask<Boolean>(new Callable<Boolean>() { public Boolean call() throws Exception { return loadCommands(); } }); threadService.execute(loadCommandsTask); log.info("initializing IO ..."); FutureTask<Boolean> initIOTask = new FutureTask<Boolean>(new Callable<Boolean>() { public Boolean call() throws Exception { return initImageIO(); } }); threadService.execute(initIOTask); log.info("initializing status bar ..."); initializeStatusBar(); reportTime(startTime, "initialized status bar"); log.info("initializing work space ..."); initializeWorkspace(); reportTime(startTime, "initialized work space"); loadCommandsTask.get(); reportTime(startTime, "loaded commands"); log.info("binding container ..."); bindContainer(); reportTime(startTime, "bound container"); log.info("initializing tool bar ..."); initializeToolBar(); reportTime(startTime, "initialized tool bar"); log.info("initializing menu ..."); initializeMenu(); reportTime(startTime, "initialized menu"); initIOTask.get(); reportTime(startTime, "initialized IO"); initResources.get(); reportTime(startTime, "initialized resources"); initExceptionHandler(); }
From source file:components.TreeDemo.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event dispatch thread./*from w w w.j a v a 2s . c om*/ */ private static void createAndShowGUI() { if (useSystemLookAndFeel) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.err.println("Couldn't use system look and feel."); } } //Create and set up the window. JFrame frame = new JFrame("TreeDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Add content to the window. frame.add(new TreeDemo()); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:QueryConnector.java
/** Gestione degli eventi **/ public static void attach(XComponentContext componentContext, XModel model) { QueryConnector connector = null;/* w w w . j a v a2 s. co m*/ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); connector = new QueryConnector(model, componentContext); connector.attach(); } catch (Exception ex) { if (connector != null) connector.enableEdit(); ExceptionDialog.show(null, ex); } }
From source file:org.moeaframework.examples.gp.regression.SymbolicRegressionGUI.java
/** * Runs the given symbolic regression problem instance, displaying * intermediate results in a GUI.//from w w w . j av a2 s . c o m * * @param problem the symbolic regression problem instance */ public static void runDemo(SymbolicRegression problem) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // couldn't set system look and feel, continue with default } // setup the GUI SymbolicRegressionGUI gui = new SymbolicRegressionGUI(problem); // setup and construct the GP solver int generation = 0; int maxGenerations = 1000; Algorithm algorithm = null; Properties properties = new Properties(); properties.setProperty("populationSize", "500"); try { algorithm = AlgorithmFactory.getInstance().getAlgorithm("GA", properties, problem); // run the GP solver while ((generation < maxGenerations) && !gui.isCanceled()) { algorithm.step(); generation++; gui.update(algorithm.getResult().get(0), generation, maxGenerations); } } finally { if (algorithm != null) { algorithm.terminate(); } } }