Example usage for javax.swing UIManager getSystemLookAndFeelClassName

List of usage examples for javax.swing UIManager getSystemLookAndFeelClassName

Introduction

In this page you can find the example usage for javax.swing UIManager getSystemLookAndFeelClassName.

Prototype

public static String getSystemLookAndFeelClassName() 

Source Link

Document

Returns the name of the LookAndFeel class that implements the native system look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.

Usage

From source file:test.uk.co.modularaudio.util.swing.lwtc.TestShowLWTCToggleButtonGroup.java

public static void main(final String[] args) throws Exception {
    if (LWTCCtrlTestingConstants.USE_LAF) {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }//  w  w w.  j  ava 2s. c om
    final TestShowLWTCToggleButtonGroup t = new TestShowLWTCToggleButtonGroup();
    t.go();
}

From source file:test.uk.co.modularaudio.util.swing.table.layeredpane.LaunchTestLayeredPaneTable.java

/**
 * @param args/*  w  w  w . j ava  2s .  c  o m*/
 */
public static void main(final String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                //               LookAndFeel newLookAndFeel = new SubstanceBusinessLookAndFeel();
                //               UIManager.setLookAndFeel( newLookAndFeel );
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

                final LaunchTestLayeredPaneTable launcher = new LaunchTestLayeredPaneTable();
                launcher.setVisible(true);
            } catch (final Exception e) {
                log.error(e);
            }
        }
    });
}

From source file:tvbrowser.core.Settings.java

private static String getDefaultLookAndFeelClassName() {
    String lnf = UIManager.getSystemLookAndFeelClassName();
    if (StringUtils.containsIgnoreCase(lnf, "metal")) {
        LookAndFeelInfo[] lnfs = UIManager.getInstalledLookAndFeels();
        if (lnfs != null) {
            for (LookAndFeelInfo lookAndFeel : lnfs) {
                if (StringUtils.containsIgnoreCase(lookAndFeel.getName(), "Nimbus")) {
                    lnf = lookAndFeel.getClassName();
                }/*from  w  w  w .ja v a2s.  c  o  m*/
            }
        }
    }
    return lnf;
}

From source file:tvbrowser.TVBrowser.java

/**
 * Entry point of the application// w w  w . jav a  2  s  .c o  m
 * @param args The arguments given in the command line.
 */
public static void main(String[] args) {
    // Read the command line parameters
    parseCommandline(args);

    try {
        Toolkit.getDefaultToolkit().setDynamicLayout(
                (Boolean) Toolkit.getDefaultToolkit().getDesktopProperty("awt.dynamicLayoutSupported"));
    } catch (Exception e) {
        e.printStackTrace();
    }

    mLocalizer = util.ui.Localizer.getLocalizerFor(TVBrowser.class);

    // Check whether the TV-Browser was started in the right directory
    if (!new File("imgs").exists()) {
        String msg = "Please start TV-Browser in the TV-Browser directory!";
        if (mLocalizer != null) {
            msg = mLocalizer.msg("error.2", "Please start TV-Browser in the TV-Browser directory!");
        }
        JOptionPane.showMessageDialog(null, msg);
        System.exit(1);
    }

    if (mIsTransportable) {
        System.getProperties().remove("propertiesfile");
    }

    // setup logging

    // Get the default Logger
    Logger mainLogger = Logger.getLogger("");

    // Use a even simpler Formatter for console logging
    mainLogger.getHandlers()[0].setFormatter(createFormatter());

    if (mIsTransportable) {
        File settingsDir = new File("settings");
        try {
            File test = File.createTempFile("write", "test", settingsDir);
            test.delete();
        } catch (IOException e) {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e1) {
                //ignore
            }

            JTextArea area = new JTextArea(mLocalizer.msg("error.noWriteRightsText",
                    "You are using the transportable version of TV-Browser but you have no writing rights in the settings directory:\n\n{0}'\n\nTV-Browser will be closed.",
                    settingsDir.getAbsolutePath()));
            area.setFont(new JLabel().getFont());
            area.setFont(area.getFont().deriveFont((float) 14).deriveFont(Font.BOLD));
            area.setLineWrap(true);
            area.setWrapStyleWord(true);
            area.setPreferredSize(new Dimension(500, 100));
            area.setEditable(false);
            area.setBorder(null);
            area.setOpaque(false);

            JOptionPane.showMessageDialog(null, area,
                    mLocalizer.msg("error.noWriteRightsTitle", "No write rights in settings directory"),
                    JOptionPane.ERROR_MESSAGE);
            System.exit(1);
        }
    }

    // Load the settings
    Settings.loadSettings();
    Locale.setDefault(new Locale(Settings.propLanguage.getString(), Settings.propCountry.getString()));

    if (Settings.propFirstStartDate.getDate() == null) {
        Settings.propFirstStartDate.setDate(Date.getCurrentDate());
    }

    if (!createLockFile()) {
        updateLookAndFeel();
        showTVBrowserIsAlreadyRunningMessageBox();
    }

    String logDirectory = Settings.propLogdirectory.getString();
    if (logDirectory != null) {
        try {
            File logDir = new File(logDirectory);
            logDir.mkdirs();
            mainLogger.addHandler(
                    new FileLoggingHandler(logDir.getAbsolutePath() + "/tvbrowser.log", createFormatter()));
        } catch (IOException exc) {
            String msg = mLocalizer.msg("error.4", "Can't create log file.");
            ErrorHandler.handle(msg, exc);
        }
    } else {
        // if no logging is configured, show WARNING or worse for normal usage, show everything for unstable versions
        if (TVBrowser.isStable()) {
            mainLogger.setLevel(Level.WARNING);
        }
    }

    // log warning for OpenJDK users
    if (!isJavaImplementationSupported()) {
        mainLogger.warning(SUN_JAVA_WARNING);
    }

    //Update plugin on version change
    if (Settings.propTVBrowserVersion.getVersion() != null
            && VERSION.compareTo(Settings.propTVBrowserVersion.getVersion()) > 0) {
        updateLookAndFeel();
        updatePluginsOnVersionChange();
    }

    // Capture unhandled exceptions
    //System.setErr(new PrintStream(new MonitoringErrorStream()));

    String timezone = Settings.propTimezone.getString();
    if (timezone != null) {
        TimeZone.setDefault(TimeZone.getTimeZone(timezone));
    }
    mLog.info("Using timezone " + TimeZone.getDefault().getDisplayName());

    // refresh the localizers because we know the language now
    Localizer.emptyLocalizerCache();
    mLocalizer = Localizer.getLocalizerFor(TVBrowser.class);
    ProgramInfo.resetLocalizer();
    ReminderPlugin.resetLocalizer();
    Date.resetLocalizer();
    ProgramFieldType.resetLocalizer();

    // Set the proxy settings
    updateProxySettings();

    // Set the String to use for indicating the user agent in http requests
    System.setProperty("http.agent", MAINWINDOW_TITLE);

    Version tmpVer = Settings.propTVBrowserVersion.getVersion();
    final Version currentVersion = tmpVer != null
            ? new Version(tmpVer.getMajor(), tmpVer.getMinor(),
                    Settings.propTVBrowserVersionIsStable.getBoolean())
            : tmpVer;

    /*TODO Create an update service for installed TV data services that doesn't
     *     work with TV-Browser 3.0 and updates for them are known.
     */
    if (!isTransportable() && Launch.isOsWindowsNtBranch() && currentVersion != null
            && currentVersion.compareTo(new Version(3, 0, true)) < 0) {
        String tvDataDir = Settings.propTVDataDirectory.getString().replace("/", File.separator);

        if (!tvDataDir.startsWith(System.getenv("appdata"))) {
            StringBuilder oldDefaultTvDataDir = new StringBuilder(System.getProperty("user.home"))
                    .append(File.separator).append("TV-Browser").append(File.separator).append("tvdata");

            if (oldDefaultTvDataDir.toString().equals(tvDataDir)) {
                Settings.propTVDataDirectory.setString(Settings.propTVDataDirectory.getDefault());
            }
        }
    }

    Settings.propTVBrowserVersion.setVersion(VERSION);
    Settings.propTVBrowserVersionIsStable.setBoolean(VERSION.isStable());

    final Splash splash;

    if (mShowSplashScreen && Settings.propSplashShow.getBoolean()) {
        splash = new SplashScreen(Settings.propSplashImage.getString(), Settings.propSplashTextPosX.getInt(),
                Settings.propSplashTextPosY.getInt(), Settings.propSplashForegroundColor.getColor());
    } else {
        splash = new DummySplash();
    }
    splash.showSplash();

    /* Initialize the MarkedProgramsList */
    MarkedProgramsList.getInstance();

    /*Maybe there are tvdataservices to install (.jar.inst files)*/
    PluginLoader.getInstance().installPendingPlugins();

    PluginLoader.getInstance().loadAllPlugins();

    mLog.info("Loading TV listings service...");
    splash.setMessage(mLocalizer.msg("splash.dataService", "Loading TV listings service..."));
    TvDataServiceProxyManager.getInstance().init();
    ChannelList.createForTvBrowserStart();

    ChannelList.initSubscribedChannels();

    if (!lookAndFeelInitialized) {
        mLog.info("Loading Look&Feel...");
        splash.setMessage(mLocalizer.msg("splash.laf", "Loading look and feel..."));

        updateLookAndFeel();
    }

    mLog.info("Loading plugins...");
    splash.setMessage(mLocalizer.msg("splash.plugins", "Loading plugins..."));
    try {
        PluginProxyManager.getInstance().init();
    } catch (TvBrowserException exc) {
        ErrorHandler.handle(exc);
    }

    splash.setMessage(mLocalizer.msg("splash.tvData", "Checking TV database..."));

    mLog.info("Checking TV listings inventory...");
    TvDataBase.getInstance().checkTvDataInventory();

    mLog.info("Starting up...");
    splash.setMessage(mLocalizer.msg("splash.ui", "Starting up..."));

    Toolkit.getDefaultToolkit().getSystemEventQueue().push(new TextComponentPopupEventQueue());

    // Init the UI
    final boolean fStartMinimized = Settings.propMinimizeAfterStartup.getBoolean() || mMinimized;
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            initUi(splash, fStartMinimized);

            new Thread("Start finished callbacks") {
                public void run() {
                    setPriority(Thread.MIN_PRIORITY);

                    mLog.info("Deleting expired TV listings...");
                    TvDataBase.getInstance().deleteExpiredFiles(1, false);

                    // first reset "starting" flag of mainframe
                    mainFrame.handleTvBrowserStartFinished();

                    // initialize program info for fast reaction to program table click
                    ProgramInfo.getInstance().handleTvBrowserStartFinished();

                    // load reminders and favorites
                    ReminderPlugin.getInstance().handleTvBrowserStartFinished();
                    FavoritesPlugin.getInstance().handleTvBrowserStartFinished();

                    // now handle all plugins and services
                    GlobalPluginProgramFormatingManager.getInstance();
                    PluginProxyManager.getInstance().fireTvBrowserStartFinished();
                    TvDataServiceProxyManager.getInstance().fireTvBrowserStartFinished();

                    // finally submit plugin caused updates to database
                    TvDataBase.getInstance().handleTvBrowserStartFinished();

                    startPeriodicSaveSettings();

                }
            }.start();
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    ChannelList.completeChannelLoading();
                    initializeAutomaticDownload();
                    if (Launch.isOsWindowsNtBranch()) {
                        try {
                            RegistryKey desktopSettings = new RegistryKey(RootKey.HKEY_CURRENT_USER,
                                    "Control Panel\\Desktop");
                            RegistryValue autoEnd = desktopSettings.getValue("AutoEndTasks");

                            if (autoEnd.getData().equals("1")) {
                                RegistryValue killWait = desktopSettings.getValue("WaitToKillAppTimeout");

                                int i = Integer.parseInt(killWait.getData().toString());

                                if (i < 5000) {
                                    JOptionPane pane = new JOptionPane();

                                    String cancel = mLocalizer.msg("registryCancel", "Close TV-Browser");
                                    String dontDoIt = mLocalizer.msg("registryJumpOver", "Not this time");

                                    pane.setOptions(new String[] { Localizer.getLocalization(Localizer.I18N_OK),
                                            dontDoIt, cancel });
                                    pane.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION);
                                    pane.setMessageType(JOptionPane.WARNING_MESSAGE);
                                    pane.setMessage(mLocalizer.msg("registryWarning",
                                            "The fast shutdown of Windows is activated.\nThe timeout to wait for before Windows is closing an application is too short,\nto give TV-Browser enough time to save all settings.\n\nThe setting hasn't the default value. It was changed by a tool or by you.\nTV-Browser will now try to change the timeout.\n\nIf you don't want to change this timeout select 'Not this time' or 'Close TV-Browser'."));

                                    pane.setInitialValue(mLocalizer.msg("registryCancel", "Close TV-Browser"));

                                    JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(mainFrame),
                                            UIManager.getString("OptionPane.messageDialogTitle"));
                                    d.setModal(true);
                                    UiUtilities.centerAndShow(d);

                                    if (pane.getValue() == null || pane.getValue().equals(cancel)) {
                                        mainFrame.quit();
                                    } else if (!pane.getValue().equals(dontDoIt)) {
                                        try {
                                            killWait.setData("5000");
                                            desktopSettings.setValue(killWait);
                                            JOptionPane.showMessageDialog(
                                                    UiUtilities.getLastModalChildOf(mainFrame),
                                                    mLocalizer.msg("registryChanged",
                                                            "The timeout was changed successfully.\nPlease reboot Windows!"));
                                        } catch (Exception registySetting) {
                                            JOptionPane.showMessageDialog(
                                                    UiUtilities.getLastModalChildOf(mainFrame),
                                                    mLocalizer.msg("registryNotChanged",
                                                            "<html>The Registry value couldn't be changed. Maybe you haven't the right to do it.<br>If it is so contact you Administrator and let him do it for you.<br><br><b><Attention:/b> The following description is for experts. If you change or delete the wrong value in the Registry you could destroy your Windows installation.<br><br>To get no warning on TV-Browser start the Registry value <b>WaitToKillAppTimeout</b> in the Registry path<br><b>HKEY_CURRENT_USER\\Control Panel\\Desktop</b> have to be at least <b>5000</b> or the value for <b>AutoEndTasks</b> in the same path have to be <b>0</b>.</html>"),
                                                    Localizer.getLocalization(Localizer.I18N_ERROR),
                                                    JOptionPane.ERROR_MESSAGE);
                                        }
                                    }
                                }
                            }
                        } catch (Throwable registry) {
                        }
                    }

                    if (currentVersion != null && currentVersion.compareTo(new Version(2, 71, false)) < 0) {
                        if (Settings.propProgramPanelMarkedMinPriorityColor.getColor()
                                .equals(Settings.propProgramPanelMarkedMinPriorityColor.getDefaultColor())) {
                            Settings.propProgramPanelMarkedMinPriorityColor.setColor(new Color(255, 0, 0, 30));
                        }
                        if (Settings.propProgramPanelMarkedMediumPriorityColor.getColor()
                                .equals(Settings.propProgramPanelMarkedMediumPriorityColor.getDefaultColor())) {
                            Settings.propProgramPanelMarkedMediumPriorityColor
                                    .setColor(new Color(140, 255, 0, 60));
                        }
                        if (Settings.propProgramPanelMarkedHigherMediumPriorityColor.getColor().equals(
                                Settings.propProgramPanelMarkedHigherMediumPriorityColor.getDefaultColor())) {
                            Settings.propProgramPanelMarkedHigherMediumPriorityColor
                                    .setColor(new Color(255, 255, 0, 60));
                        }
                        if (Settings.propProgramPanelMarkedMaxPriorityColor.getColor()
                                .equals(Settings.propProgramPanelMarkedMaxPriorityColor.getDefaultColor())) {
                            Settings.propProgramPanelMarkedMaxPriorityColor
                                    .setColor(new Color(255, 180, 0, 110));
                        }
                    }

                    // check if user should select picture settings
                    if (currentVersion != null && currentVersion.compareTo(new Version(2, 22)) < 0) {
                        TvBrowserPictureSettingsUpdateDialog.createAndShow(mainFrame);
                    } else if (currentVersion != null
                            && currentVersion.compareTo(new Version(2, 51, true)) < 0) {
                        Settings.propAcceptedLicenseArrForServiceIds.setStringArray(new String[0]);
                    }

                    if (currentVersion != null && currentVersion.compareTo(new Version(2, 60, true)) < 0) {
                        int startOfDay = Settings.propProgramTableStartOfDay.getInt();
                        int endOfDay = Settings.propProgramTableEndOfDay.getInt();

                        if (endOfDay - startOfDay < -1) {
                            Settings.propProgramTableEndOfDay.setInt(startOfDay);

                            JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(mainFrame),
                                    mLocalizer.msg("timeInfoText",
                                            "The time range of the program table was corrected because the defined day was shorter than 24 hours.\n\nIf the program table should show less than 24h use a time filter for that. That time filter can be selected\nto be the default filter by selecting it in the filter settings and pressing on the button 'Default'."),
                                    mLocalizer.msg("timeInfoTitle", "Times corrected"),
                                    JOptionPane.INFORMATION_MESSAGE);
                            Settings.handleChangedSettings();
                        }
                    }
                    MainFrame.getInstance().getProgramTableScrollPane().requestFocusInWindow();
                }
            });
        }
    });

    // register the shutdown hook
    Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook") {
        public void run() {
            deleteLockFile();
            MainFrame.getInstance().quit(false);
        }
    });
}

From source file:us.derfers.tribex.rapids.Loader.java

/**
 * Starts loading the GUI. Sets Swing look and feel, then loads the GUI using the GUI_Swing object.
 * @param escapedFile The content .rsm file to load UI elements from.
 * @param parent The (optional) parent Object, Eg, a JFrame or JPanel.
 * @param engine The JavaScript engine to pass to GUI_Swing
 *//*  w w  w .  j av  a  2s.c  o m*/
public void loadAll(String escapedFile) {

    //Attempt to load .rsm file filePath
    try {

        //Parse filePath
        Document doc = Utilities.XMLStringToDocument(escapedFile);

        //Stabilize parsed document
        doc.normalize();

        //Get body element
        NodeList mainNodeList = doc.getElementsByTagName("rsm");

        //Make sure there is only ONE body element
        if (mainNodeList.getLength() == 1) {
            debugMsg("Parsing Main Element", 4);
            //Get rsm Element
            Element mainElement = (Element) mainNodeList.item(0);

            debugMsg("Setting Theme", 4);
            //If the mainElement has the attribute "theme"
            if (mainElement.getAttributeNode("theme") != null) {
                //Get the value of the attribute theme for the body element
                Attr swing_Theme = mainElement.getAttributeNode("theme");

                //See if the rsm file specifies a theme other than camo
                if (swing_Theme != null && !swing_Theme.getNodeValue().equalsIgnoreCase("camo")) {
                    try {
                        //Split the theme into the jarfile and the classname (JARFILE.jar : com.stuff.stuff.theme)
                        String[] splitTheme = swing_Theme.getNodeValue().split(":");

                        System.out.println(splitTheme[0].trim() + "**" + splitTheme[1].trim());
                        //Attempt to dynamically load the specified jarfile
                        Sys.addJarToClasspath(Globals.getCWD(splitTheme[0].trim()));

                        //Attempt to set the look'n'feel to the theme specified by the file
                        UIManager.setLookAndFeel(splitTheme[1].trim());

                        debugMsg("Look and Feel set to '" + swing_Theme.getNodeValue() + "'.", 3);

                    } catch (Exception e) {
                        //If unable to set to .rsm's theme, use the system look'n'feel
                        try {
                            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                        } catch (Exception a) {
                            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
                        }
                        Utilities.showError(
                                "Error loading Look and Feel Specified, Look and Feel set to System");
                        e.printStackTrace();

                    }
                } else {
                    //If swing_Theme == camo or is not set, use the system look'n'feel
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (Exception a) {
                        a.printStackTrace();
                        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
                    }
                    debugMsg("Look and Feel (Swing) set to System", 3);
                }
            } else {
                //If swing_Theme == camo or is not set, use the system look'n'feel
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (Exception a) {
                    a.printStackTrace();
                    UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
                }
                debugMsg("Look and Feel (Swing) set to System", 3);

            }

            //Parse styles
            for (int i = 0; i < mainElement.getElementsByTagName("style").getLength(); i++) {
                Element styleElement = (Element) mainElement.getElementsByTagName("style").item(i);
                //Load all styles from the style tags
                if (styleElement.getAttributeNode("href") != null) {
                    loadStyles(null, styleElement.getTextContent());
                } else {
                    loadStyles(styleElement.getTextContent(), null);

                }
            }

            //Parse links
            for (int i = 0; i < mainElement.getElementsByTagName("link").getLength(); i++) {
                Element linkElement = (Element) mainElement.getElementsByTagName("link").item(i);
                parseLinks(linkElement, engine);
            }

            //Parse JavaScript in <script> tags
            Main.loader.loadJS(escapedFile, engine);

            //Parse GUI
            for (int i = 0; i < mainElement.getElementsByTagName("window").getLength(); i++) {
                GUI.loadWindow((Element) mainElement.getElementsByTagName("window").item(i), engine);
            }

        } else { //There was more than one body tag, or 0 body tags

            //Display Error and quit, as we cannot recover from an abnormally formatted file
            Utilities.showError("Error: More or less than one <rsm> tag in '" + escapedFile + "'.\n\n"
                    + "Please add ONE <rsm> tag to '" + escapedFile + "'.");
            System.exit(1);
        }

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }

}

From source file:usr.erichschroeter.conversionsvg.ConversionSvg.java

public static void main(String[] args) {
    // license to use JIDE software (JDAF, Grids, Components, etc)
    // com.jidesoft.utils.Lm.verifyLicense("Erich Schroeter",
    // "ConversionSVG", "3.99ekleZZE3EXVgbI0hck9kXuHYXJh2");
    Options o = new Options();
    o.addOption(new Option("v", "version", false, "display the version"));
    o.addOption(new Option("V", "verbose", false, "display verbose information"));
    o.addOption(new Option("h", "help", false, "display this menu"));
    o.addOption(new Option("I", "inkscape", true, "the location of Inkscape executable"));

    try {/*from  www.  j av a2  s.co m*/
        CommandLineParser parser = new GnuParser();
        CommandLine commandline = parser.parse(o, args);

        if (commandline.hasOption("h")) {
            HelpFormatter f = new HelpFormatter();
            f.printHelp("conversionsvg [Options]", o);
            System.exit(0);
        }
        if (commandline.hasOption("v")) {
            System.out.printf("%s%n", new ConversionSvgApplication().getVersion());
            System.exit(0);
        }
        isVerbose = commandline.hasOption("V");

        if (commandline.hasOption("I")) {
            Inkscape.setExecutable(new File(commandline.getOptionValue("I")));
        } else {
            Inkscape.setExecutable(Inkscape.findExecutable());
        }

        args = commandline.getArgs();
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }

    if (isVerbose) {
        File inkscape = Inkscape.getExecutable();
        if (inkscape == null) {
            System.out.println("could not find Inkscape installed");
        } else {
            System.out.printf("found Inkscape installed at <%s>%n", Inkscape.getExecutable().getAbsolutePath());
        }
    }

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception exception) {
                exception.printStackTrace();
            }

            // // install the preference values
            // int width = getApplicationPreferences()
            // .getInt("window.size.width", 600);
            // int height =
            // getApplicationPreferences().getInt("window.size.height",
            // 350);
            // int x =
            // getApplicationPreferences().getInt("window.location.x", 100);
            // int y =
            // getApplicationPreferences().getInt("window.location.y", 100);
            //
            // getApplicationWindow().setPreferredSize(new Dimension(width,
            // height));
            // getApplicationWindow().setLocation(new Point(x, y));
            //
            // // initialize the thread pool
            // int corePoolSize = getApplicationPreferences().getInt(
            // "thread_pool.core_size", 10);
            // int maximumPoolSize = getApplicationPreferences().getInt(
            // "thread_pool.max_size", 20);
            // int keepAliveTime = getApplicationPreferences().getInt(
            // "thread_pool.keep_alive_time", 10);
            // // The thread pool used to start Inkscape processes
            // PriorityBlockingQueue<Runnable> queue = new
            // PriorityBlockingQueue<Runnable>(
            // corePoolSize);
            // setThreadPool(new ThreadPoolExecutor(corePoolSize,
            // maximumPoolSize,
            // keepAliveTime, TimeUnit.SECONDS, queue));
            //
            // getApplicationWindow().setVisible(true);

            ConversionSvgApplication app = new ConversionSvgApplication();
            JRibbon ribbon = app.createApplicationRibbon();
            ribbon.setApplicationMenu(app.createApplicationRibbonMenu());
            for (RibbonTask t : app.createApplicationRibbonTasks()) {
                ribbon.addTask(t);
            }
            app.installApplicationRibbon(ribbon);
            app.getApplicationWindow().pack();
            app.run();

        }
    });
}

From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java

protected static void initializeLaF() {
    invokeSwingAndWait(() -> {/*from www  .jav  a 2  s  .  co  m*/
        try {
            UIManager.setLookAndFeel(LIGHT_THEME);
            SubstanceCortex.GlobalScope.setColorizationFactor(1.0D);
            SubstanceCortex.GlobalScope.registerComponentPlugin(new SubstanceSwingxPlugin());

            if (System.getProperty("os.name").toLowerCase().equals("linux")) {
                // Try to apply GNOME Shell fix
                try {
                    final Toolkit xToolkit = Toolkit.getDefaultToolkit();
                    java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass()
                            .getDeclaredField("awtAppClassName");
                    awtAppClassNameField.setAccessible(true);
                    awtAppClassNameField.set(xToolkit, Lang.get("title"));
                    awtAppClassNameField.setAccessible(false);
                } catch (final Exception e) {
                    LOG.warn("Could not apply X fix", e);
                }
            }

        } catch (final Exception e) {
            LOG.warn("Could not apply Substance LaF, falling back to system LaF", e);
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (final Exception e1) {
                LOG.warn("Failed to load System LaF as well, falling back to keeping the default LaF", e1);
            }
        }
    });
}

From source file:VASSAL.launch.StartUp.java

protected void initUIProperties() {
    System.setProperty("swing.aatext", "true"); //$NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("swing.boldMetal", "false"); //$NON-NLS-1$ //$NON-NLS-2$
    System.setProperty("awt.useSystemAAFontSettings", "on"); //$NON-NLS-1$ //$NON-NLS-2$

    if (!SystemUtils.IS_OS_WINDOWS) {
        // use native LookAndFeel
        // NB: This must be after Mac-specific properties
        try {// w w  w.j a  v a 2s .com
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            ErrorDialog.bug(e);
        } catch (IllegalAccessException e) {
            ErrorDialog.bug(e);
        } catch (InstantiationException e) {
            ErrorDialog.bug(e);
        } catch (UnsupportedLookAndFeelException e) {
            ErrorDialog.bug(e);
        }
    }

    // Ensure consistent behavior in NOT consuming "mousePressed" events
    // upon a JPopupMenu closing (added for Windows L&F, but others might
    // also be affected.
    UIManager.put("PopupMenu.consumeEventOnClose", Boolean.FALSE);
}

From source file:visolate.Main.java

public static void main(final String[] argv) {

    CommandLineParser parser = new PosixParser();
    Options options = new Options();
    options.addOption("x", "flip-x", false, "flip around x axis");
    options.addOption("y", "flip-y", false, "flip around y axis");
    options.addOption("a", "absolute", false, "use absolute cooridnates");
    options.addOption("d", "dpi", true, "dpi to use for rastering");
    options.addOption("A", "auto", false, "auto-mode (run, save and exit)");
    options.addOption("o", "outfile", true, "name of output file");

    options.addOption("h", "help", false, "display this help and exit");
    options.addOption("V", "version", false, "output version information and exit");

    CommandLine commandline;//from w w w . j  a va  2 s .  c o  m
    try {
        commandline = parser.parse(options, argv);
    } catch (ParseException e) {
        System.err.println(e.getLocalizedMessage());
        System.exit(1);
        return; // make it clear to the compiler that the following code is not run
    }

    if (commandline.hasOption("version")) {
        System.out.println(APPNAME);
        return;
    }

    if (commandline.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("visolate [options] [filename]", options);
        return;
    }

    if (commandline.getArgs().length >= 2) {
        System.err.println("Error: Too many arguments.");
        System.exit(1);
    }

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //TODO: Make look and feel options
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    final JFrame frame = new JFrame(APPNAME);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocation(DEF_LOC_X, DEF_LOC_Y);

    // Add the Enter key to the forward traversal keys, so fields loose focus
    // when using it in a field and we don't need to set up both, an ActionListener
    // and a FocusListener for each text/number field.
    Set<AWTKeyStroke> forwardKeys = new HashSet<AWTKeyStroke>(
            frame.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
    Set<AWTKeyStroke> newForwardKeys = new HashSet<AWTKeyStroke>(forwardKeys);
    newForwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    frame.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newForwardKeys);

    final Visolate visolate = new Visolate();
    visolate.commandline = commandline;

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(visolate, "Center");
    contentPane.setBackground(Color.WHITE);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {

            frame.pack();
            frame.setVisible(true);

            if (visolate.commandline.getArgs().length == 1) {
                visolate.loadFile(new File(visolate.commandline.getArgs()[0]));
            } else {
                visolate.loadDemo();
            }

            if (visolate.commandline.hasOption("auto")) {
                System.out.println("Automatic processing enabled! Files will be overwritten without asking!");
                visolate.auto_mode = true;
            }

            if (visolate.commandline.hasOption("dpi")) {
                visolate.getDisplay().setDPI(Integer.parseInt(visolate.commandline.getOptionValue("dpi")));
            }

            if (visolate.commandline.hasOption("flip-x")) {
                visolate.model.setFlipX(true);
            }
            if (visolate.commandline.hasOption("flip-y")) {
                visolate.model.setFlipY(true);
            }

            if (visolate.commandline.hasOption("absolute")) {
                visolate.setAbsoluteCoordinates(true);
            }

            if (visolate.commandline.hasOption("outfile")) {
                visolate.setGcodeFile(visolate.commandline.getOptionValue("outfile"));
            }

            if (visolate.commandline.hasOption("auto")) {
                System.out.println("now starting fixing topology due to automatic mode");
                visolate.processstatus = 1;

                visolate.fixTopology();
                // fix.Topology() calls visolate.processFinished after its done. Also, the Toolpathprocessor does so. processstatus discriminates this.
            }

            visolate.model.rebuild();
        }

    });
}

From source file:widoco.gui.GuiController.java

public GuiController() {
    this.state = State.initial;
    config = new Configuration();
    System.out.println("\n\n--WIzard for DOCumenting Ontologies (WIDOCO).\n https://w3id.org/widoco/\n");
    System.out.println("\nYou are launching WIDOCO GUI\n");
    System.out.println("\nTo use WIDOCO through the command line please do:\n");
    System.out.println(/*from   www. j a v a  2 s . c om*/
            "java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] [-getOntologyMetadata] [-oops] "
                    + "[-rewriteAll] [-crossRef] [-saveConfig configOutFile] [-lang lang1-lang2] [-includeImportedOntologies] [-htaccess] [-licensius] [-webVowl] "
                    + "[-ignoreIndividuals] [-includeAnnotationProperties] [-analytics analyticsCode] [-doNotDisplaySerializations] [-displayDirectImportsOnly]"
                    + "[-rewriteBase rewriteBasePath]. \nSee more information in https://github.com/dgarijo/Widoco/#how-to-use-widoco\n");
    //read logo
    try {
        gui = new GuiStep1(this);
        gui.setVisible(true);
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error while launching the GUI" + e.getMessage());
    }
}