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:net.sourceforge.squirrel_sql.client.Application.java

/**
 * Setup applications Look and Feel.// www  .j  a v a  2s  . c  o  m
 */
private void setupLookAndFeel(ApplicationArguments args) {
    /* 
     * Don't prevent the user from overriding the laf is they choose to use 
     * Swing's default laf prop 
     */
    String userSpecifiedOverride = System.getProperty("swing.defaultlaf");
    if (userSpecifiedOverride != null && !"".equals(userSpecifiedOverride)) {
        return;
    }

    String lafClassName = args.useNativeLAF() ? UIManager.getSystemLookAndFeelClassName()
            : MetalLookAndFeel.class.getName();

    if (!args.useDefaultMetalTheme()) {
        MetalLookAndFeel.setCurrentTheme(new AllBluesBoldMetalTheme());
    }

    try {
        // The following is a work-around for the problem on Mac OS X where
        // the Apple LAF delegates to the Swing Popup factory but then
        // tries to set a 90% alpha on the underlying Cocoa window, which
        // will always be null if you're using JGoodies L&F
        // see http://www.caimito.net/pebble/2005/07/26/1122392314480.html#comment1127522262179
        // This has no effect on Linux/Windows
        PopupFactory.setSharedInstance(new PopupFactory());

        UIManager.setLookAndFeel(lafClassName);
    } catch (Exception ex) {
        // i18n[Application.error.setlaf=Error setting LAF]
        s_log.error(s_stringMgr.getString("Application.error.setlaf"), ex);
    }
}

From source file:net.technicpack.launcher.LauncherMain.java

public static void main(String[] args) {
    try {/*w w w .j av a2s  .c  o m*/
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        Utils.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
    }

    StartupParameters params = new StartupParameters(args);
    try {
        new JCommander(params, args);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    Relauncher launcher = new Relauncher(
            new HttpUpdateStream("http://beta.technicpack.net/api/launcher/version/"));
    TechnicSettings settings = null;

    try {
        settings = SettingsFactory.buildSettingsObject(launcher.getRunningPath(LauncherMain.class),
                params.isMover());
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
    }

    if (settings == null) {
        ResourceLoader installerResources = new ResourceLoader("net", "technicpack", "launcher", "resources");
        installerResources.setLocale(ResourceLoader.DEFAULT_LOCALE);
        InstallerFrame dialog = new InstallerFrame(installerResources, params);
        dialog.setVisible(true);
        return;
    }

    LauncherDirectories directories = new TechnicLauncherDirectories(settings.getTechnicRoot());
    ResourceLoader resources = new ResourceLoader("net", "technicpack", "launcher", "resources");
    resources.setLocale(settings.getLanguageCode());

    setupLogging(directories, resources);

    boolean needsReboot = false;

    if (System.getProperty("awt.useSystemAAFontSettings") == null
            || !System.getProperty("awt.useSystemAAFontSettings").equals("lcd"))
        needsReboot = true;
    else if (!Boolean.parseBoolean(System.getProperty("java.net.preferIPv4Stack")))
        needsReboot = true;

    if (params.isLauncher())
        startLauncher(settings, params, directories, resources);
    else if (params.isMover())
        startMover(params, launcher);
    else if (needsReboot && StringUtils.isNumeric(resources.getLauncherBuild())) {
        // ^^^^^
        //The debugger can't really relaunch so double check the build number to make sure we're operating in a valid environment
        launcher.launch(null, LauncherMain.class, params.getArgs());
        return;
    } else {
        updateAndRelaunch(params, directories, resources, settings, launcher);
    }
}

From source file:net.ytbolg.mcxa.MCLaucherXA.java

/**
 * @param args the command line arguments
 * @throws java.lang.Exception// w w w .  j  a  va  2s . c  om
 */
public static void main(String args[]) throws InterruptedException {
    //System.out.println(System.getProperty("os.name"));
    //Test.main(null);
    System.out.println(System.getProperty("os.arch"));
    //  System.getProperties().list(System.out);
    try {
        String tx = new File(".").getCanonicalPath();
        if (tx.endsWith("\\")) {
            tx = tx.substring(0, tx.length() - 1);
        }
        File f2 = new File(tx + "/update.note");
        System.out.println(f2.exists() + f2.toString());
        if (f2.exists()) {
            //        Thread.sleep(3000);
            String x = ReadFile(f2.toString());
            System.out.println(x);
            f2.deleteOnExit();
            new File(x).delete();

        }
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        //      Test t = new Test("H:\\mclaucherxa\\");
        //  t.countJavaFile(t.projectPath);
        GameInfo.tpf = getTpf();
        //    GameInfo.JavaPath = "java";
        String fgf = System.getProperty("os.name").contains("Linux") ? "'" : "\"";
        if (!System.getProperty("os.name").contains("Windows")) {
            //       GameInfo.JavaPath = "java";
            GameInfo.JavaPath = System.getProperty("java.home") + tpf + "bin" + tpf + "java";
        } else {
            //  GameInfo.JavaPath = "java";
            GameInfo.JavaPath = System.getProperty("java.home") + tpf + "bin" + tpf + "java.exe";
        }
        //  GameInfo.GameDir = "J:\\NewZM\\client\\.minecraft";
        //   GameInfoGet.getGameVersions();
        GameInfo.Rundir = new File(".").getCanonicalPath();
        System.out.println(GameInfo.Rundir);
        if (GameInfo.Rundir.endsWith("\\")) {
            GameInfo.Rundir = GameInfo.Rundir.substring(0, GameInfo.Rundir.length() - 1);
        }
        System.out.println(GameInfo.Rundir);
        GameInfo.GameDir = GameInfo.Rundir + GameInfo.tpf + ".minecraft";

        //??
        String Files[] = { "sChinese.lang", "tChinese.lang", "English.lang" };
        String Langs[] = { LangFile.sChinese, LangFile.tChinese, LangFile.english };
        ArrayList<File> file = new ArrayList<>();

        for (int i = 0; i < Files.length; i++) {
            File f = new File(GameInfo.Rundir + tpf + "MCXA.Lang" + tpf + Files[i]);
            File par = f.getParentFile();
            if (par.isFile() || !par.exists()) {
                par.mkdir();
            }
            System.out.println(f);
            if (!f.exists()) {
                f.createNewFile();
                file.add(f);
            }
        }
        for (int i = 0; i < file.size(); i++) {

            FileWriter fw = new FileWriter(file.get(i));
            fw.write(Langs[i]);
            fw.close();
        }
        // getClass().getResource("/sChinese.lang").

        if (!(new File(GameInfo.Rundir + tpf + "MCXA.json")).exists()) {
            System.out.println("?");
            new File(GameInfo.Rundir + tpf + "MCXA.json").createNewFile();
            FileWriter fw = new FileWriter(GameInfo.Rundir + tpf + "MCXA.json");
            fw.write("{}");
            fw.close();
            //   p.load(new FileInputStream(GameInfo.Rundir + tpf + "MCXA.cfg"));
            String playerxxx = String.valueOf(new Random().nextInt(999));
            if (playerxxx.length() != 3) {
                for (int i = 1; i < playerxxx.length() - 1; i++) {
                    playerxxx = "0" + playerxxx;
                }
            }
            Config.Load(new File(GameInfo.Rundir + tpf + "MCXA.json"));
            Config.setConfig("username", "player" + playerxxx);
            Config.setConfig("lastgameversion", "0");
            Config.setConfig("lastmemory", "1500");
            //   Config.setConfig("showlauchinfowindows", "true");
            Config.setConfig("showlauchinfo", "true");
            Config.setConfig("ifclose", "true");
            Config.setConfig("zhengbanmima", "");
            Config.setConfig("DownSou", "1");
            Config.setConfig("Lang", "sChinese.lang");
            Config.setConfig("iszhengban", "false");
            Config.setConfig("GameDir", GameInfo.GameDir);
            Config.setConfig("JavaPath", GameInfo.JavaPath);
            Config.setConfig("isDuli", "false");
            Config.Save();

        } else {
            Config.Load(new File(GameInfo.Rundir + tpf + "MCXA.json"));
        }
        GameInfo.GameDir = Config.getConfig("GameDir");
        if (new File(GameInfo.GameDir).exists() == false) {
            Config.setConfig("GameDir", GameInfo.Rundir + tpf + ".minecraft");
            GameInfo.GameDir = Config.getConfig("GameDir");
            Config.Save();
        }
        GameInfo.JavaPath = Config.getConfig("JavaPath");
        Lang.Load(new File(GameInfo.Rundir + tpf + "MCXA.Lang" + tpf + Config.getConfig("Lang")));
        //
        //    p.load(new FileInputStream(GameInfo.Rundir + tpf + "MCXA.cfg"));
        //p.store(new FileOutputStream(GameInfo.Rundir + tpf + "MCXA.cfg"), "");
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
        /*        try {
         for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
         if ("Nimbus".equals(info.getName())) {
         javax.swing.UIManager.setLookAndFeel(info.getClassName());
         break;
         }
         }
         } catch (ClassNotFoundException ex) {
         java.util.logging.Logger.getLogger(MCLaucherXA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
         } catch (InstantiationException ex) {
         java.util.logging.Logger.getLogger(MCLaucherXA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
         } catch (IllegalAccessException ex) {
         java.util.logging.Logger.getLogger(MCLaucherXA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
         java.util.logging.Logger.getLogger(MCLaucherXA.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
         }*/
        //</editor-fold>
        //System.getProperties().list(System.out);

        /* Create and display the form */
        if (!new File(GameInfo.GameDir).exists()) {
            JOptionPane.showMessageDialog(null, Lang.getLang("Main_NoMinecraftDir"));
            File fi = new File(GameInfo.GameDir + GameInfo.tpf + "versions");
            fi.mkdirs();

            // System.exit(0);
        }
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MCLaucherXA().setVisible(true);
            }

        });
    } catch (HeadlessException | IOException | ClassNotFoundException | IllegalAccessException
            | InstantiationException | UnsupportedLookAndFeelException e) {
        e.printStackTrace();
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.App.java

public static void main(final String[] args) {
    LOG.debug("Starting Indigo Application");
    try {//from ww w . j av a2s  .  c o  m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        LOG.error("Error setting look and feel", ex);
    }

    if ((args.length > 0) && (args[0] != null)
            && ((args[0].equalsIgnoreCase("metadata")) || (args[0].equalsIgnoreCase("/metadata")))) {
        final IMetaDataConfigurator configurator = new MetaDataConfigurator();
        final MetaDataConfiguratorPresenter presenter = new MetaDataConfiguratorPresenter(configurator);
        configurator.setPresenter(presenter);
        presenter.setup();
    } else {
        final IManualDepositMainFrame deposit = new ManualDepositMain();
        AppProperties appProperties = null;
        try {
            appProperties = new AppProperties();
        } catch (Exception ex) {
            final String message = "Error loading application properties - " + ex.getMessage();
            LOG.error(message, ex);
            JOptionPane.showMessageDialog(null, message, "Error Loading Application Properties",
                    JOptionPane.ERROR_MESSAGE);
            System.exit(-1);
        }
        final ILoginView login = new Login(null, true, appProperties.getApplicationData().getSettingsPath());
        try {
            final LoginPresenter loginPresenter = new LoginPresenter(login, appProperties);
            final ManualDepositPresenter presenter = new ManualDepositPresenter(deposit, login, loginPresenter,
                    appProperties);
            deposit.setPresenter(presenter);
            presenter.setupScreen();
        } catch (Exception ex) {
            LOG.error("Error running Indigo", ex);
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Error running Indigo",
                    JOptionPane.ERROR_MESSAGE);
            System.exit(-1);
        }
    }
}

From source file:ome.formats.importer.gui.FileQueueChooser.java

/**
 * Main for testing (debugging only)//from w  w w . j av a2s . co  m
 * 
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) {

    String laf = UIManager.getSystemLookAndFeelClassName();
    //laf = "ch.randelshofer.quaqua.QuaquaLookAndFeel";
    //laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
    //laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
    //laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    //laf = "javax.swing.plaf.metal.MetalLookAndFeel";

    System.err.println(laf);

    try {
        UIManager.setLookAndFeel(laf);
    } catch (Exception e) {
        System.err.println(laf + " not supported.");
    }
    System.err.println("laf: " + UIManager.getLookAndFeel());

    FileQueueChooser c = new FileQueueChooser(null, null);

    JFrame f = new JFrame();
    c.setMultiSelectionEnabled(true);

    f.getContentPane().add(c);
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
}

From source file:ome.formats.importer.gui.FileQueueTable.java

/**
 * Main for testing (debugging only)// w ww  .java2 s . co m
 * 
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) {

    String laf = UIManager.getSystemLookAndFeelClassName();
    //laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
    //laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
    //laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    //laf = "javax.swing.plaf.metal.MetalLookAndFeel";

    try {
        UIManager.setLookAndFeel(laf);
    } catch (Exception e) {
        System.err.println(laf + " not supported.");
    }

    FileQueueTable q = new FileQueueTable();
    JFrame f = new JFrame();
    f.getContentPane().add(q);
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
}

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Start up the application, display the main window and the login dialog.
 *            /*from ww  w  . jav a2s. c  o m*/
 * @param args 
 */
public static void main(String[] args) {
    try {
        LogAppenderProxy.configure(new File(IniFileLoader.LOGFILE));
    } catch (Exception e) {
        GuiImporter.LoggingDisabledNotification();
    }
    ImportConfig config = new ImportConfig(args.length > 0 ? new File(args[0]) : null);
    config.configureDebug(null); // Uses ini

    config.loadAll();
    config.loadGui();
    USE_QUAQUA = config.getUseQuaqua();

    String laf = UIManager.getSystemLookAndFeelClassName();

    //laf = "ch.randelshofer.quaqua.QuaquaLookAndFeel";
    //laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
    //laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
    //laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    //laf = "javax.swing.plaf.metal.MetalLookAndFeel";

    if (laf.equals("apple.laf.AquaLookAndFeel") && USE_QUAQUA) {
        System.setProperty("Quaqua.design", "panther");

        try {
            UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
        } catch (Exception e) {
            System.err.println(laf + " not supported.");
        }
    } else {
        try {
            UIManager.setLookAndFeel(laf);
        } catch (Exception e) {
            System.err.println(laf + " not supported.");
        }
    }

    /* Alternative GTK file chooser
    if ("GTK look and feel".equals(UIManager.getLookAndFeel().getName())) {
    UIManager.put("FileChooserUI", "eu.kostia.gtkjfilechooser.ui.GtkFileChooserUI");
      }
     */

    new GuiImporter(config);
}

From source file:ome.formats.importer.gui.OptionsDialog.java

/**
 * Internal testing main (for debugging only)
 * @param args//from   w w  w .j a v  a2 s  . co m
 * @throws Exception 
 */
public static void main(String[] args) {

    String laf = UIManager.getSystemLookAndFeelClassName();
    //laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
    //laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    //laf = "javax.swing.plaf.metal.MetalLookAndFeel";
    //laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";

    try {
        UIManager.setLookAndFeel(laf);
    } catch (Exception e) {
        System.err.println(laf + " not supported.");
    }

    ImportConfig config = new ImportConfig(null);

    OptionsDialog dialog = new OptionsDialog(config, null, "Optional Settings", true);
    if (dialog != null)
        System.exit(0);
}

From source file:ome.formats.importer.gui.SPWDialog.java

/**
 * Internal testing main (for debugging only)
 * @param args/*w ww.  ja  v  a  2s. c  o  m*/
 * @throws Exception 
 */
public static void main(String[] args) {

    String laf = UIManager.getSystemLookAndFeelClassName();
    //laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
    //laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    //laf = "javax.swing.plaf.metal.MetalLookAndFeel";
    //laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";

    try {
        UIManager.setLookAndFeel(laf);
    } catch (Exception e) {
        System.err.println(laf + " not supported.");
    }

    SPWDialog dialog = new SPWDialog(null, null, "Plate Import Dialog", true, null);
    if (dialog != null)
        System.exit(0);
}

From source file:org.apache.fop.cli.CommandLineOptions.java

/**
 * Parses the command line arguments.//from   w  w  w.  j  av  a  2s. c  om
 *
 * @param args the command line arguments.
 * @throws FOPException for general errors
 * @throws IOException if the the configuration file could not be loaded
 * @return true if the processing can continue, false to abort
 */
public boolean parse(String[] args) throws FOPException, IOException {
    boolean optionsParsed = true;

    try {
        optionsParsed = parseOptions(args);
        if (optionsParsed) {
            if (showConfiguration == Boolean.TRUE) {
                dumpConfiguration();
            }
            checkSettings();
            setUserConfig();
            if (flushCache) {
                flushCache();
            }
            //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());
            foUserAgent.setConserveMemoryPolicy(conserveMemoryPolicy);
            if (!useComplexScriptFeatures) {
                foUserAgent.setComplexScriptFeaturesEnabled(false);
            }
        } else {
            return false;
        }
    } catch (FOPException e) {
        printUsage(System.err);
        throw e;
    } catch (java.io.FileNotFoundException e) {
        printUsage(System.err);
        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(foUserAgent, inputHandler, true, true);
        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(foUserAgent);

        //Tell the XMLRenderer to mimic the target renderer
        xmlRenderer.mimicRenderer(targetRenderer);

        //Make sure the prepared XMLRenderer is used
        foUserAgent.setRendererOverride(xmlRenderer);
    } else if (MimeConstants.MIME_FOP_IF.equals(outputmode) && mimicRenderer != null) {
        // render from FO to Intermediate Format
        IFSerializer serializer = new IFSerializer();
        serializer.setContext(new IFContext(foUserAgent));

        IFDocumentHandler targetHandler = foUserAgent.getRendererFactory().createDocumentHandler(foUserAgent,
                mimicRenderer);
        serializer.mimicDocumentHandler(targetHandler);

        //Make sure the prepared serializer is used
        foUserAgent.setDocumentHandlerOverride(serializer);
    }
    return true;
}