List of usage examples for javax.swing UIManager installLookAndFeel
public static void installLookAndFeel(String name, String className)
From source file:com.game.ui.views.MapPanel.java
public void buildMap(MapInformation Map) throws IOException { getMapInformation(Map);//from www . j a v a 2s .co m mapPanel = new JPanel(); mapPanel.setLayout(new GridLayout(mapRows, mapColumns)); tile = new JButton[mapRows * mapColumns]; commandCounter = 1; for (int x = 0; x < mapRows; x++) { for (int y = 0; y < mapColumns; y++) { tile[commandCounter - 1] = new JButton(); (tile[commandCounter - 1]).setActionCommand("" + commandCounter); tile[commandCounter - 1].addActionListener(this); mapPanel.add(tile[commandCounter - 1]); tileInformation = pathMap.get(commandCounter); if (tileInformation != null) { mapPathPoints(); if (tileInformation.isEndTile()) { mapEndPoints(); } if (tileInformation.isStartTile()) { mapStartPoints(); numberofPlayers++; } if (tileInformation.getEnemy() != null) { mapEnemyPoints(tileInformation); numberofEnemys++; } } commandCounter++; } } UIManager.installLookAndFeel("SeaGlass", "com.seaglasslookandfeel.SeaGlassLookAndFeel"); wrapperPanel.add(mapPanel, BorderLayout.CENTER); add(wrapperPanel); pack(); setExtendedState(JFrame.MAXIMIZED_BOTH); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); setMaximizedBounds(env.getMaximumWindowBounds()); setVisible(true); }
From source file:net.sf.firemox.Magic.java
/** * @param args/*from w w w.j a v a 2 s .c o m*/ * the command line arguments * @throws Exception */ public static void main(String[] args) throws Exception { Log.init(); Log.debug("MP v" + IdConst.VERSION + ", jre:" + System.getProperty("java.runtime.version") + ", jvm:" + System.getProperty("java.vm.version") + ",os:" + System.getProperty("os.name") + ", res:" + Toolkit.getDefaultToolkit().getScreenSize().width + "x" + Toolkit.getDefaultToolkit().getScreenSize().height + ", root:" + MToolKit.getRootDir()); System.setProperty("swing.aatext", "true"); System.setProperty(SubstanceLookAndFeel.WATERMARK_IMAGE_PROPERTY, MToolKit.getIconPath(Play.ZONE_NAME + "/hardwoodfloor.png")); final File substancelafFile = MToolKit.getFile(FILE_SUBSTANCE_PROPERTIES); if (substancelafFile == null) { Log.warn("Unable to locate '" + FILE_SUBSTANCE_PROPERTIES + "' file, you are using the command line with wrong configuration. See http://www.firemox.org/dev/project.html documentation"); } else { System.getProperties().load(new FileInputStream(substancelafFile)); } MToolKit.defaultFont = new Font("Arial", 0, 11); try { if (args.length > 0) { final String[] args2 = new String[args.length - 1]; System.arraycopy(args, 1, args2, 0, args.length - 1); if ("-rebuild".equals(args[0])) { XmlConfiguration.main(args2); } else if ("-oracle2xml".equals(args[0])) { Oracle2Xml.main(args2); } else if ("-batch".equals(args[0])) { if ("-server".equals(args[1])) { batchMode = BATCH_SERVER; } else if ("-client".equals(args[1])) { batchMode = BATCH_CLIENT; } } else { Log.error("Unknown options '" + Arrays.toString(args) + "'\nUsage : java -jar starter.jar <options>, where options are :\n" + "\t-rebuild -game <tbs name> [-x] [-d] [-v] [-h] [-f] [-n]\n" + "\t-oracle2xml -f <oracle file> -d <output directory> [-v] [-h]"); } System.exit(0); return; } if (batchMode == -1 && !"Mac OS X".equals(System.getProperty("os.name"))) { splash = new SplashScreen(MToolKit.getIconPath("splash.jpg"), null, 2000); } // language settings LanguageManager.initLanguageManager(Configuration.getString("language", "auto")); } catch (Throwable t) { Log.error("START-ERROR : \n\t" + t.getMessage()); System.exit(1); return; } Log.debug("MP Language : " + LanguageManager.getLanguage().getName()); speparateAvatar = Toolkit.getDefaultToolkit().getScreenSize().height > 768; // verify the java version, minimal is 1.5 if (new JavaVersion().compareTo(new JavaVersion(IdConst.MINIMAL_JRE)) == -1) { Log.error(LanguageManager.getString("wrongjava") + IdConst.MINIMAL_JRE); } // load look and feel settings lookAndFeelName = Configuration.getString("preferred", MUIManager.LF_SUBSTANCE_CLASSNAME); // try { // FileInputStream in= new FileInputStream("MAGIC.TTF"); // MToolKit.defaultFont= Font.createFont(Font.TRUETYPE_FONT, in); // in.close(); // MToolKit.defaultFont= MToolKit.defaultFont.deriveFont(Font.BOLD, 11); // } // catch (FileNotFoundException e) { // System.out.println("editorfont.ttf not found, using default."); // } // catch (Exception ex) { // ex.printStackTrace(); // } // Read available L&F final LinkedList<Pair<String, String>> lfList = new LinkedList<Pair<String, String>>(); try { BufferedReader buffReader = new BufferedReader( new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_THEME_SETTINGS))); String line; while ((line = buffReader.readLine()) != null) { line = line.trim(); if (!line.startsWith("#")) { final int index = line.indexOf(';'); if (index != -1) { lfList.add(new Pair<String, String>(line.substring(0, index), line.substring(index + 1))); } } } IOUtils.closeQuietly(buffReader); } catch (Throwable e) { // no place for resolve this problem Log.debug("Error reading L&F properties : " + e.getMessage()); } for (Pair<String, String> pair : lfList) { UIManager.installLookAndFeel(pair.key, pair.value); } // install L&F if (SkinLF.isSkinLF(lookAndFeelName)) { // is a SkinLF Look & Feel /* * Make sure we have a nice window decoration. */ SkinLF.installSkinLF(lookAndFeelName); } else { // is Metal Look & Feel if (!MToolKit.isAvailableLookAndFeel(lookAndFeelName)) { // preferred look&feel is not available JOptionPane.showMessageDialog(magicForm, LanguageManager.getString("preferredlfpb", lookAndFeelName), LanguageManager.getString("error"), JOptionPane.INFORMATION_MESSAGE); setDefaultUI(); } // Install the preferred LookAndFeel newLAF = MToolKit.geLookAndFeel(lookAndFeelName); frameDecorated = newLAF.getSupportsWindowDecorations(); /* * Make sure we have a nice window decoration. */ JFrame.setDefaultLookAndFeelDecorated(frameDecorated); JDialog.setDefaultLookAndFeelDecorated(frameDecorated); UIManager.setLookAndFeel(MToolKit.geLookAndFeel(lookAndFeelName)); } // Start main thread try { new Magic(); SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER); } catch (Throwable e) { Log.fatal("In main thread, occurred exception : ", e); ConnectionManager.closeConnexions(); return; } }
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; }//from w ww. jav a 2 s .c om } } 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:se.trixon.jota.client.Client.java
private void displayGui() { if (GraphicsEnvironment.isHeadless()) { Xlog.timedErr("Can't open gui when in headless mode."); Jota.exit(1);/*from ww w .j ava 2 s. c om*/ return; } UIManager.installLookAndFeel("Darcula", "com.bulenkov.darcula.DarculaLaf"); if (mOptions.isAutostartServer() && !mManager.isConnected()) { try { if (serverStart()) { mManager.connect(SystemHelper.getHostname(), mOptions.getAutostartServerPort()); } } catch (URISyntaxException | IOException | NotBoundException ex) { Xlog.timedErr(ex.getLocalizedMessage()); } } if (mOptions.isForceLookAndFeel()) { try { UIManager.setLookAndFeel(SwingHelper.getLookAndFeelClassName(mOptions.getLookAndFeel())); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Xlog.timedErr(ex.getMessage()); } } java.awt.EventQueue.invokeLater(() -> { mMainFrame = new MainFrame(); addServerEventListener(mMainFrame); mMainFrame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); mManager.disconnect(); } }); mMainFrame.setVisible(true); }); }
From source file:tvbrowser.TVBrowser.java
private static void updateLookAndFeel() { try {//from w w w. j a v a 2 s . com if (OperatingSystem.isWindows()) { UIManager.installLookAndFeel("Extended Windows", "com.jgoodies.looks.windows.WindowsLookAndFeel"); } UIManager.installLookAndFeel("Plastic", "com.jgoodies.looks.plastic.PlasticLookAndFeel"); UIManager.installLookAndFeel("Plastic 3D", "com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); UIManager.installLookAndFeel("Plastic XP", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel"); UIManager.installLookAndFeel("Skin", "com.l2fprod.gui.plaf.skin.SkinLookAndFeel"); /* Map<String, SkinInfo> substanceSkins = SubstanceLookAndFeel.getAllSkins(); if (substanceSkins != null) { for (SkinInfo skin : substanceSkins.values()) { String className = skin.getClassName(); UIManager.installLookAndFeel("Substance " + skin.getDisplayName(), StringUtils.replace(StringUtils.replace(className, "Skin", "LookAndFeel"), "skin.", "skin.Substance")); } } */ } catch (Exception e1) { // ignore any exception for optional skins e1.printStackTrace(); } if (Settings.propLookAndFeel.getString().equals("com.l2fprod.gui.plaf.skin.SkinLookAndFeel")) { String themepack = Settings.propSkinLFThemepack.getString(); try { File themepackFile = new File(themepack); if (!themepackFile.exists()) { themepackFile = new File(Settings.getUserDirectoryName(), themepack); } if (!themepackFile.exists() && OperatingSystem.isMacOs()) { themepackFile = new File("/Library/Application Support/TV-Browser/", themepack); } SkinLookAndFeel.setSkin(SkinLookAndFeel.loadThemePack(themepackFile.getAbsolutePath())); } catch (Exception exc) { ErrorHandler.handle("Could not load themepack.\nSkinLF is disabled now", exc); Settings.propLookAndFeel.setString(Settings.propLookAndFeel.getDefault()); } } else if (Settings.propLookAndFeel.getString().startsWith("com.jgoodies")) { com.jgoodies.looks.Options.setPopupDropShadowEnabled(Settings.propJGoodiesShadow.getBoolean()); UIManager.put("jgoodies.popupDropShadowEnabled", Boolean.valueOf(Settings.propJGoodiesShadow.getBoolean())); try { LookUtils.setLookAndTheme( (LookAndFeel) Class.forName(Settings.propLookAndFeel.getString()).newInstance(), Class.forName(Settings.propJGoodiesTheme.getString()).newInstance()); } catch (Throwable e) { ErrorHandler.handle("Could not load themepack.\nJGoodies is disabled now", e); Settings.propLookAndFeel.setString(Settings.propLookAndFeel.getDefault()); } } if (curLookAndFeel == null || !curLookAndFeel.equals(Settings.propLookAndFeel.getString())) { try { curLookAndFeel = Settings.propLookAndFeel.getString(); // check if LnF is still available boolean foundCurrent = lookAndFeelExists(curLookAndFeel); // reset look and feel? if (!foundCurrent) { if (JOptionPane.showConfirmDialog(null, mLocalizer.msg("lnfMissing", "The look and feel '{0}' is no longer available,\nso the default look and feel will be used.\n\nDo you want to set the look and feel option to the default look and feel?", curLookAndFeel), mLocalizer.msg("lnfMissing.title", "Look and feel missing"), JOptionPane.WARNING_MESSAGE | JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { Settings.propLookAndFeel.resetToDefault(); curLookAndFeel = Settings.propLookAndFeel.getString(); foundCurrent = true; } } if (foundCurrent) { UIThreadRunner.invokeAndWait(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(curLookAndFeel); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } mLog.info("setting look and feel to " + curLookAndFeel); } }); } } catch (Exception exc) { String msg = mLocalizer.msg("error.1", "Unable to set look and feel.", exc); ErrorHandler.handle(msg, exc); } } // set colors for action pane at UIManager UIManager.put("TaskPane.foreGround", UIManager.get("Button.foreground")); if (UIManager.getColor("List.selectionBackground") == null) { UIManager.put("List.selectionBackground", UIManager.getColor("Tree.selectionBackground")); } if (UIManager.getColor("List.selectionForeground") == null) { UIManager.put("List.selectionForeground", UIManager.getColor("Tree.selectionForeground")); } if (UIManager.getColor("MenuItem.selectionForeground") == null) { UIManager.put("MenuItem.selectionForeground", UIManager.getColor("Tree.selectionForeground")); } if (UIManager.getColor("ComboBox.disabledForeground") == null) { UIManager.put("ComboBox.disabledForeground", Color.gray); } if (mainFrame != null) { SwingUtilities.updateComponentTreeUI(mainFrame); mainFrame.validate(); } lookAndFeelInitialized = true; }