List of usage examples for javax.swing UIManager getInstalledLookAndFeels
public static LookAndFeelInfo[] getInstalledLookAndFeels()
From source file:uk.ac.ox.cbrg.cpfp.uploadapp.UploadApplet.java
@Override public void init() { // Set errorFlag to false - no errors yet ;-) errorFlag = false;//from w w w . j a v a 2 s. co m // <PARAM> tag handling uploadFiles = new Vector<UploadFile>(); uploadURL = getParameter("UPLOADURL"); if (uploadURL == null) { uploadURL = ""; } fileExtensions = getParameter("EXTENSIONS"); if (fileExtensions == null) { fileExtensions = ""; } chunkSize = Long.parseLong(getParameter("CHUNKSIZE")); if (chunkSize == 0) { chunkSize = 10485760; // 10MB } // Get cookies from browser so session can be used for uploads try { JSObject myBrowser = (JSObject) JSObject.getWindow(this); JSObject myDocument = (JSObject) myBrowser.getMember("document"); browserCookie = (String) myDocument.getMember("cookie"); jso = JSObject.getWindow(this); } catch (Exception e) { e.printStackTrace(); } // Use Nimbus look and feel rather than default try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (UnsupportedLookAndFeelException e) { } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } // Invoke Applet try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { initComponents(); } }); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private void createLookAndFeel() { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); boolean hasNimbus = false; boolean hasWindows = false; for (int i = 0; i < lfs.length; i++) { if (lfs[i].getClassName().equals("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel")) { hasNimbus = true;// w w w . ja v a 2 s . co m } else if (lfs[i].getClassName().equals("com.sun.java.swing.plaf.windows.WindowsLookAndFeel")) { hasWindows = true; } } String lafName = null; if (hasNimbus) { lafName = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"; } else if (hasWindows) { lafName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; } else { lafName = "javax.swing.plaf.metal.MetalLookAndFeel"; } try { UIManager.setLookAndFeel(lafName); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } }
From source file:org.peerfact.impl.service.aggregation.skyeye.visualization.SkyNetVisualization.java
private static void createLookAndFeel() { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); boolean hasNimbus = false; boolean hasWindows = false; for (int i = 0; i < lfs.length; i++) { if (lfs[i].getClassName().equals("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel")) { hasNimbus = true;//ww w .j av a 2 s. c o m } else if (lfs[i].getClassName().equals("com.sun.java.swing.plaf.windows.WindowsLookAndFeel")) { hasWindows = true; } } String lafName = null; if (hasNimbus) { lafName = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"; } else if (hasWindows) { lafName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; } else { lafName = "javax.swing.plaf.metal.MetalLookAndFeel"; } try { UIManager.setLookAndFeel(lafName); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } }
From source file:org.pegadi.client.ApplicationLauncher.java
protected void setTheme(String theme) { //TODO: fix nullpointerexception log.debug("theme: {}", theme); String lfTheme;/* www . ja v a 2 s. c o m*/ if (theme.equalsIgnoreCase("system")) { lfTheme = UIManager.getSystemLookAndFeelClassName(); } else if (theme.equalsIgnoreCase("swing")) { lfTheme = UIManager.getCrossPlatformLookAndFeelClassName(); lfTheme = UIManager.getSystemLookAndFeelClassName(); } else if (theme.equalsIgnoreCase("gtk")) { lfTheme = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; //DEBUG lfTheme = UIManager.getSystemLookAndFeelClassName(); } else { log.error("Invalid L&F theme"); throw new IllegalArgumentException("'" + theme + "' is not a supported L&F"); } if (!lfTheme.equals(UIManager.getLookAndFeel().getName())) { try { UIManager.setLookAndFeel(lfTheme); } catch (Exception e) { log.warn("Unable to set selected L&F, swapping to a default L&F"); UIManager.LookAndFeelInfo[] installedLF = UIManager.getInstalledLookAndFeels(); try { UIManager.setLookAndFeel(installedLF[0].getClassName()); } catch (Exception e2) { log.error("Unable to load any L&F, exiting", e2); System.exit(-1); } } try { log.debug("attempting to update componenttreeui"); SwingUtilities.updateComponentTreeUI(this.getContentPane()); } catch (Exception swe) { log.error("Unable to update component tree", swe); } } pack(); //Might be the cause of occasional NullpointEx due to system //not being able to locate LookAndFeel }
From source file:de.huxhorn.lilith.swing.ApplicationPreferences.java
public ApplicationPreferences() { lastSourceNamesModified = -1;/* w ww . ja v a 2 s . c o m*/ lastConditionsModified = -1; propertyChangeSupport = new PropertyChangeSupport(this); startupApplicationPath = getApplicationPath(); installedLookAndFeels = new ArrayList<>(); for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { installedLookAndFeels.add(info.getName()); } Collections.sort(installedLookAndFeels); groovyConditionsPath = new File(startupApplicationPath, "conditions"); if (groovyConditionsPath.mkdirs()) { // groovy conditions directory was generated, create examples... installExampleConditions(); } groovyClipboardFormattersPath = new File(startupApplicationPath, "clipboardFormatters"); if (groovyClipboardFormattersPath.mkdirs()) { // groovy clipboardFormatters directory was generated, create examples... installExampleClipboardFormatters(); } }
From source file:de.huxhorn.lilith.Lilith.java
public static void startUI(final String appTitle) { final Logger logger = LoggerFactory.getLogger(Lilith.class); UIManager.installLookAndFeel("JGoodies Windows", "com.jgoodies.looks.windows.WindowsLookAndFeel"); UIManager.installLookAndFeel("JGoodies Plastic", "com.jgoodies.looks.plastic.PlasticLookAndFeel"); UIManager.installLookAndFeel("JGoodies Plastic 3D", "com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); UIManager.installLookAndFeel("JGoodies Plastic XP", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); // Substance requires 1.6 UIManager.installLookAndFeel("Substance Dark - Twilight", "org.pushingpixels.substance.api.skin.SubstanceTwilightLookAndFeel"); UIManager.installLookAndFeel("Substance Light - Business", "org.pushingpixels.substance.api.skin.SubstanceBusinessLookAndFeel"); //UIManager.installLookAndFeel("Napkin", "net.sourceforge.napkinlaf.NapkinLookAndFeel"); // look & feels must be installed before creation of ApplicationPreferences. ApplicationPreferences applicationPreferences = new ApplicationPreferences(); // init look & feel String lookAndFeelName = applicationPreferences.getLookAndFeel(); String systemLookAndFeelClassName = UIManager.getSystemLookAndFeelClassName(); String lookAndFeelClassName = systemLookAndFeelClassName; if (lookAndFeelName != null) { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (lookAndFeelName.equals(info.getName())) { lookAndFeelClassName = info.getClassName(); break; }/* w w w . j a v a2 s .c o m*/ } } try { UIManager.setLookAndFeel(lookAndFeelClassName); } catch (Throwable e) { if (logger.isWarnEnabled()) logger.warn("Failed to set look&feel to '{}'.", lookAndFeelClassName, e); if (!lookAndFeelClassName.equals(systemLookAndFeelClassName)) { try { UIManager.setLookAndFeel(systemLookAndFeelClassName); lookAndFeelClassName = systemLookAndFeelClassName; } catch (Throwable e2) { if (logger.isWarnEnabled()) logger.warn("Failed to set look&feel to '{}'.", systemLookAndFeelClassName, e); lookAndFeelClassName = null; } } } boolean screenMenuBar = false; if (systemLookAndFeelClassName.equals(lookAndFeelClassName)) { // This instance of application is only used to query some info. The real one is in MainFrame. Application application = new DefaultApplication(); if (application.isMac()) { // Use Apple Aqua L&F screen menu bar if available; set property before any frames created try { System.setProperty(APPLE_SCREEN_MENU_BAR_SYSTEM_PROPERTY, "true"); screenMenuBar = true; } catch (Throwable e) { try { screenMenuBar = Boolean .parseBoolean(System.getProperty(APPLE_SCREEN_MENU_BAR_SYSTEM_PROPERTY, "false")); } catch (Throwable e2) { // ignore } } } } applicationPreferences.setUsingScreenMenuBar(screenMenuBar); boolean splashScreenDisabled = applicationPreferences.isSplashScreenDisabled(); try { SplashScreen splashScreen = null; if (!splashScreenDisabled) { CreateSplashRunnable createRunnable = new CreateSplashRunnable(appTitle); EventQueue.invokeAndWait(createRunnable); splashScreen = createRunnable.getSplashScreen(); Thread.sleep(500); // so the splash gets the chance to get displayed :( updateSplashStatus(splashScreen, "Initialized application preferences..."); } File startupApplicationPath = applicationPreferences.getStartupApplicationPath(); if (startupApplicationPath.mkdirs()) { if (logger.isDebugEnabled()) logger.debug("Created '{}'.", startupApplicationPath.getAbsolutePath()); } // System.err redirection { File errorLog = new File(startupApplicationPath, "errors.log"); boolean freshFile = false; if (!errorLog.isFile()) { freshFile = true; } try { FileOutputStream fos = new FileOutputStream(errorLog, true); PrintStream ps = new PrintStream(fos, true, StandardCharsets.UTF_8.name()); if (!freshFile) { ps.println("----------------------------------------"); } String currentDateTime = DateTimeFormatters.DATETIME_IN_SYSTEM_ZONE_SPACE.format(Instant.now()); ps.println("Started " + APP_NAME + " V" + APP_VERSION + " at " + currentDateTime); System.setErr(ps); if (logger.isInfoEnabled()) logger.info("Writing System.err to '{}'.", errorLog.getAbsolutePath()); } catch (FileNotFoundException | UnsupportedEncodingException e) { e.printStackTrace(); } } File prevPathFile = new File(startupApplicationPath, ApplicationPreferences.PREVIOUS_APPLICATION_PATH_FILENAME); if (prevPathFile.isFile()) { updateSplashStatus(splashScreen, "Moving application path content..."); moveApplicationPathContent(prevPathFile, startupApplicationPath); } if (!applicationPreferences.isLicensed()) { hideSplashScreen(splashScreen); LicenseAgreementDialog licenseDialog = new LicenseAgreementDialog(); licenseDialog.setAlwaysOnTop(true); licenseDialog.setAutoRequestFocus(true); Windows.showWindow(licenseDialog, null, true); if (licenseDialog.isLicenseAgreed()) { applicationPreferences.setLicensed(true); } else { if (logger.isWarnEnabled()) logger.warn("Didn't accept license! Exiting..."); System.exit(-1); } } updateSplashStatus(splashScreen, "Creating main window..."); CreateMainFrameRunnable createMain = new CreateMainFrameRunnable(applicationPreferences, splashScreen, appTitle); EventQueue.invokeAndWait(createMain); final MainFrame frame = createMain.getMainFrame(); if (logger.isDebugEnabled()) logger.debug("After show..."); updateSplashStatus(splashScreen, "Initializing application..."); EventQueue.invokeAndWait(frame::startUp); hideSplashScreen(splashScreen); mainFrame = frame; } catch (InterruptedException ex) { if (logger.isInfoEnabled()) logger.info("Interrupted...", ex); IOUtilities.interruptIfNecessary(ex); } catch (InvocationTargetException ex) { if (logger.isWarnEnabled()) logger.warn("InvocationTargetException...", ex); if (logger.isWarnEnabled()) logger.warn("Target-Exception: ", ex.getTargetException()); } }
From source file:net.sourceforge.entrainer.gui.EntrainerFX.java
private JMenu getLookAndFeels() { JMenu menu = new JMenu("Look and Feel"); addMnemonic(menu, KeyEvent.VK_K); LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels(); Map<String, List<LookAndFeelInfo>> sortedInfos = sortInfos(infos); for (String key : sortedInfos.keySet()) { List<LookAndFeelInfo> sorted = sortedInfos.get(key); JMenu lafMenu = new JMenu(key); for (LookAndFeelInfo info : sorted) { JMenuItem item = addLookAndFeel(info); lafMenu.add(item);/*w w w . j a va2 s . co m*/ } if (!sorted.isEmpty()) { menu.add(lafMenu); } } return menu; }
From source file:com.pironet.tda.TDA.java
/** * tries the native look and feel on mac and windows and metal on unix (gtk still * isn't looking that nice, even in 1.6) *///from ww w . jav a2s .com private void setupLookAndFeel() { try { String plaf = "Mac,Windows,Metal"; if (System.getProperty("os.name").startsWith("Linux")) { plaf = "GTK,Mac,Windows,Metal"; } // this line needs to be implemented in order to make L&F work properly UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader()); // query list of L&Fs UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels(); if (!Strings.isNullOrEmpty(plaf)) { String[] instPlafs = plaf.split(","); UIManager.LookAndFeelInfo currentLAFI = null; search: for (final String instPlaf : instPlafs) { for (final UIManager.LookAndFeelInfo plaf1 : plafs) { currentLAFI = plaf1; if (currentLAFI.getName().startsWith(instPlaf)) { UIManager.setLookAndFeel(currentLAFI.getClassName()); // setup SANS_SERIF setUIFont(new FontUIResource("SansSerif", Font.PLAIN, Const.FONT_SIZE)); break search; } } } } if (plaf.startsWith("GTK")) { setFontSizeModifier(2); } } catch (Exception except) { setUIFont(new FontUIResource("SansSerif", Font.PLAIN, 12)); } }
From source file:jchrest.gui.Shell.java
/** * Set theme of user interface to the one named. *//*from ww w. ja va 2 s . c o m*/ private void setTheme(String theme) { try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if (theme.equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (UnsupportedLookAndFeelException e) { } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } // make sure all components are updated SwingUtilities.updateComponentTreeUI(this); // SwingUtilities.updateComponentTreeUI(_fileChooser); TODO: update FileUtilities filechooser }
From source file:gov.noaa.ncdc.iosp.avhrr.util.AvhrrLevel1B2Netcdf.java
/** * @param args// ww w .ja v a2 s .c o m * the command line arguments */ public static void main(String args[]) throws Exception { // create the Options object Options options = new Options(); options.addOption(OPTION_NOGUI, false, "command line mode"); options.addOption(OPTION_ALLVAR, false, "Process all channels"); options.addOption(OPTION_CH1, false, "Process channel 1"); options.addOption(OPTION_CH2, false, "Process channel 2"); options.addOption(OPTION_CH3, false, "Process channel 3"); options.addOption(OPTION_CH4, false, "Process channel 4"); options.addOption(OPTION_CH5, false, "Process channel 5"); options.addOption(OPTION_DEFAULT, false, "Output All Channels, Brightness Temperature and Latitude and Longitude"); options.addOption(OPTION_TEMP, false, "Output calibrated temperatures/albedos"); options.addOption(OPTION_RAW, false, "Output raw values"); options.addOption(OPTION_RADIANCE, false, "Output radiance values"); options.addOption(OPTION_LATLON, false, "Output latitude and longitude"); options.addOption(OPTION_ALLVAR, false, "Output all variables)"); options.addOption(OPTION_CLOBBER, false, "Overwrite existing netCDF file."); options.addOption(OPTION_CALIBRATION, false, "Output calibration variables"); options.addOption(OPTION_QUALITY, false, "Output quality variables."); options.addOption(OPTION_METADATA, false, "Output metadata variables."); options.addOption("memory", false, "java heap space."); Option logOption = new Option("logFile", true, "Send output to file"); options.addOption(logOption); Option outdirOption = new Option("outputdir", true, "Output Directory."); options.addOption(outdirOption); // 2nd way is by creating an Option and then adding it Option timeOption = new Option(OPTION_AVHRR, true, "Process the Level1B file"); timeOption.setRequired(false); options.addOption(timeOption); // now lets parse the input CommandLineParser parser = new BasicParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (ParseException pe) { usage(options); return; } // now lets interrogate the options and execute the relevant parts if (cmd.hasOption(OPTION_NOGUI)) { // process command line args - need to refactor this (doing this // twice--BAD!!!!!) List<String> list = processCommandLineArgs(cmd); String file = cmd.getOptionValue(OPTION_AVHRR); if (null == file) { System.out.println("You must specify a file to convert!! missing -avhrr argument"); usage(options); return; } String outdir = cmd.getOptionValue("outputdir"); if (null == outdir || outdir.trim().length() < 1) { File f = new File("."); outdir = f.getAbsolutePath(); } // try { Avhrr2Netcdf.convert(file, list, outdir); // } catch (Exception e) { // System.out.println("this blew up"); // TODO Auto-generated catch block // e.printStackTrace(); // } } else { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < info.length; i++) { // Get the name of the look and feel that is suitable // for // display to the user String className = info[i].getClassName(); } String javaLF = UIManager.getSystemLookAndFeelClassName(); try { // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); UIManager.setLookAndFeel(javaLF); } catch (ClassNotFoundException e) { // log.error(e.getMessage()); } catch (InstantiationException e) { // log.error(e.getMessage()); } catch (IllegalAccessException e) { // log.error(e.getMessage()); } catch (UnsupportedLookAndFeelException e) { // log.error(e.getMessage()); } mFrame = new AvhrrLevel1B2Netcdf(); mFrame.setVisible(true); } }); } }