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:com.antelink.sourcesquare.SourceSquare.java

public static void main(String[] args) {

    logger.debug("starting.....");

    final EventBus eventBus = new EventBus();

    AntepediaQuery query = new AntepediaQuery();

    SourceSquareEngine engine = new SourceSquareEngine(eventBus, query);

    ScanStatusManager manager = new ScanStatusManager(eventBus);
    manager.bind();/*from  w  ww.j a  v a 2s .c o  m*/

    TreeMapBuilder treemap = new TreeMapBuilder(eventBus);
    treemap.bind();

    ResultBuilder builder = new ResultBuilder(eventBus, treemap);
    builder.bind();

    final SourceSquareFSWalker walker = new SourceSquareFSWalker(engine, eventBus, treemap);
    walker.bind();

    ServerController.bind(eventBus);
    if (args.length != 0) {
        final File toScan = new File(args[0]);

        if (!toScan.isDirectory()) {
            logger.error("The argument is not a directory");
            logger.info("exiting SourceSquare");
            System.exit(0);
        }

        eventBus.fireEvent(new StartScanEvent(toScan));

        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "SourceSquare");

        logger.info("Scan complete");
        logger.info("Number of files to scan: " + ScanStatus.INSTANCE.getNbFilesToScan());
        logger.info("Number of files Scanned: " + ScanStatus.INSTANCE.getNbFilesScanned());
        logger.info("Number of files open source: " + ScanStatus.INSTANCE.getNbOSFilesFound());
    } else {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            logger.info("Error launching the UI", e);
        } catch (InstantiationException e) {
            logger.info("Error launching the UI", e);
        } catch (IllegalAccessException e) {
            logger.info("Error launching the UI", e);
        } catch (UnsupportedLookAndFeelException e) {
            logger.info("Error launching the UI", e);
        }
        SourceSquareView view = new SourceSquareView();
        SourceSquareController controller = new SourceSquareController(view, eventBus);

        ExitSourceSquareView exitView = new ExitSourceSquareView();
        ExitController exitController = new ExitController(exitView, eventBus);

        exitController.bind();
        controller.bind();
        controller.display();
    }

}

From source file:at.co.malli.relpm.RelPM.java

/**
 * @param args the command line arguments
 *///  w  w w . j  a va  2 s. c o m
public static void main(String[] args) {
    //<editor-fold defaultstate="collapsed" desc=" Create config & log directory ">
    String userHome = System.getProperty("user.home");
    File relPm = new File(userHome + "/.RelPM");
    if (!relPm.exists()) {
        boolean worked = relPm.mkdir();
        if (!worked) {
            ExceptionDisplayer.showErrorMessage(new Exception("Could not create directory "
                    + relPm.getAbsolutePath() + " to store user-settings and logs"));
            System.exit(-1);
        }
    }
    File userConfig = new File(relPm.getAbsolutePath() + "/RelPM-userconfig.xml"); //should be created...
    if (!userConfig.exists()) {
        try {
            URL resource = RelPM.class.getResource("/at/co/malli/relpm/RelPM-defaults.xml");
            FileUtils.copyURLToFile(resource, userConfig);
        } catch (IOException ex) {
            ExceptionDisplayer.showErrorMessage(new Exception("Could not copy default config. Reason:\n"
                    + ex.getClass().getName() + ": " + ex.getMessage()));
            System.exit(-1);
        }
    }
    if (!userConfig.canWrite() || !userConfig.canRead()) {
        ExceptionDisplayer.showErrorMessage(new Exception(
                "Can not read or write " + userConfig.getAbsolutePath() + "to store user-settings"));
        System.exit(-1);
    }
    if (System.getProperty("os.name").toLowerCase().contains("win")) {
        Path relPmPath = Paths.get(relPm.toURI());
        try {
            Files.setAttribute(relPmPath, "dos:hidden", true);
        } catch (IOException ex) {
            ExceptionDisplayer.showErrorMessage(new Exception("Could not set " + relPm.getAbsolutePath()
                    + " hidden. " + "Reason:\n" + ex.getClass().getName() + ": " + ex.getMessage()));
            System.exit(-1);
        }
    }
    //</editor-fold>

    logger.trace("Environment setup sucessfull");

    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code ">
    try {
        String wantedLookAndFeel = SettingsProvider.getInstance().getString("gui.lookAndFeel");
        UIManager.LookAndFeelInfo[] installed = UIManager.getInstalledLookAndFeels();
        boolean found = false;
        for (UIManager.LookAndFeelInfo info : installed) {
            if (info.getClassName().equals(wantedLookAndFeel))
                found = true;
        }
        if (found)
            UIManager.setLookAndFeel(wantedLookAndFeel);
        else
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException ex) {
        logger.error(ex.getMessage());
        ExceptionDisplayer.showErrorMessage(ex);
    } catch (InstantiationException ex) {
        logger.error(ex.getMessage());
        ExceptionDisplayer.showErrorMessage(ex);
    } catch (IllegalAccessException ex) {
        logger.error(ex.getMessage());
        ExceptionDisplayer.showErrorMessage(ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        logger.error(ex.getMessage());
        ExceptionDisplayer.showErrorMessage(ex);
    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Add GUI start to awt EventQue ">
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new MainGUI().setVisible(true);
        }
    });
    //</editor-fold>
}

From source file:net.openbyte.Launch.java

/**
 * This is the main method that allows Java to initiate the program.
 *
 * @param args the arguments to the Java program, which are ignored
 *///from  w  ww  . j a  va  2  s .c  o m
public static void main(String[] args) {
    logger.info("Checking for a new version...");
    try {
        GitHub gitHub = new GitHubBuilder().withOAuthToken("e5b60cea047a3e44d4fc83adb86ea35bda131744 ").build();
        GHRepository repository = gitHub.getUser("PizzaCrust").getRepository("OpenByte");
        for (GHRelease release : repository.listReleases()) {
            double releaseTag = Double.parseDouble(release.getTagName());
            if (CURRENT_VERSION < releaseTag) {
                logger.info("Version " + releaseTag + " has been released.");
                JOptionPane.showMessageDialog(null,
                        "Please update OpenByte to " + releaseTag
                                + " at https://github.com/PizzaCrust/OpenByte.",
                        "Update", JOptionPane.WARNING_MESSAGE);
            } else {
                logger.info("OpenByte is at the latest version.");
            }
        }
    } catch (Exception e) {
        logger.error("Failed to connect to GitHub.");
        e.printStackTrace();
    }
    logger.info("Checking for a workspace folder...");
    if (!Files.WORKSPACE_DIRECTORY.exists()) {
        logger.info("Workspace directory not found, creating one.");
        Files.WORKSPACE_DIRECTORY.mkdir();
    }
    logger.info("Checking for a plugins folder...");
    if (!Files.PLUGINS_DIRECTORY.exists()) {
        logger.info("Plugins directory not found, creating one.");
        Files.PLUGINS_DIRECTORY.mkdir();
    }
    try {
        logger.info("Grabbing and applying system look and feel...");
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e) {
        logger.info("Something went wrong when applying the look and feel, using the default one...");
        e.printStackTrace();
    }
    logger.info("Starting event manager...");
    EventManager.init();
    logger.info("Detecting plugin files...");
    File[] pluginFiles = PluginManager.getPluginFiles(Files.PLUGINS_DIRECTORY);
    logger.info("Detected " + pluginFiles.length + " plugin files in the plugins directory!");
    logger.info("Beginning load/register plugin process...");
    for (File pluginFile : pluginFiles) {
        logger.info("Loading file " + FilenameUtils.removeExtension(pluginFile.getName()) + "...");
        try {
            PluginManager.registerAndLoadPlugin(pluginFile);
        } catch (Exception e) {
            logger.error("Failed to load file " + FilenameUtils.removeExtension(pluginFile.getName()) + "!");
            e.printStackTrace();
        }
    }
    logger.info("All plugin files were loaded/registered to OpenByte.");
    logger.info("Showing graphical interface to user...");
    WelcomeFrame welcomeFrame = new WelcomeFrame();
    welcomeFrame.setVisible(true);
}

From source file:misc.TablePrintDemo3.java

/**
 * Start the application.//  w ww .  j a v a 2  s  . com
 */
public static void main(final String[] args) {
    /* Schedule for the GUI to be created and shown on the EDT */
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            /* Don't want bold fonts if we end up using metal */
            UIManager.put("swing.boldMetal", false);
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e) {
            }
            new TablePrintDemo3().setVisible(true);
        }
    });
}

From source file:PaginationExample.java

public static void main(String args[]) {

    try {//  w  w  w.j ava  2 s.  c  om
        String cn = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(cn); // Use the native L&F
    } catch (Exception cnf) {
    }
    JFrame f = new JFrame("Printing Pagination Example");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JButton printButton = new JButton("Print Pages");
    printButton.addActionListener(new PaginationExample());
    f.add("Center", printButton);
    f.pack();
    f.setVisible(true);
}

From source file:io.uploader.drive.DriveUploader.java

public static void main(String[] args) {

    if (isMacOsX()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name",
                Configuration.INSTANCE.getAppName());
        try {/*w w w.  j a  v a 2  s  .c o m*/
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | UnsupportedLookAndFeelException e) {
            logger.error("Error occurred while initializing the UI", e);
        }
    }

    Platform.setImplicitExit(false);

    // load the settings
    String settingsFile = "driveuploader-settings.xml";
    if (!new java.io.File(settingsFile).exists())
        settingsFile = null;
    try {
        Configuration.INSTANCE.load(settingsFile);
    } catch (ConfigurationException e) {
        logger.error("Error occurred while initializing the configuration", e);
    }

    try {
        // initialize the transport
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();

        // initialize the data store factory
        dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);

    } catch (IOException e) {
        logger.error("Error occurred while initializing the drive", e);
        Platform.exit();
    } catch (Throwable t) {
        logger.error("Error occurred while initializing the drive", t);
        Platform.exit();
    }

    launch(args);
}

From source file:com.o2d.pkayjava.editor.Main.java

public static void main(String[] argv) throws Exception {
    /**//from  ww  w .j  a v a  2 s . c o m
     * this should not be happening when in release mode
     */
    /**
    */

    new Main();
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}

From source file:com.uwsoft.editor.Main.java

public static void main(String[] argv) throws Exception {
    /**/* www  . j  a va 2  s .co  m*/
     * this should not be happening when in release mode
     */
    /**
    String input = getLocalArtPath("textures");
    String output = "style";
    String packFileName = "uiskin";
    TexturePacker.Settings settings =  new TexturePacker.Settings();
    settings.flattenPaths = true;
    TexturePacker.processIfModified(input, output, packFileName);
    processSplashScreenTextures();
    */

    new Main();
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}

From source file:com.heliosdecompiler.helios.bootloader.Bootloader.java

public static void main(String[] args) {
    try {/*  ww w . j  ava2s.  com*/
        if (!Constants.DATA_DIR.exists() && !Constants.DATA_DIR.mkdirs())
            throw new RuntimeException("Could not create data directory");
        if (!Constants.ADDONS_DIR.exists() && !Constants.ADDONS_DIR.mkdirs())
            throw new RuntimeException("Could not create addons directory");
        if (!Constants.SETTINGS_FILE.exists() && !Constants.SETTINGS_FILE.createNewFile())
            throw new RuntimeException("Could not create settings file");
        if (Constants.DATA_DIR.isFile())
            throw new RuntimeException("Data directory is file");
        if (Constants.ADDONS_DIR.isFile())
            throw new RuntimeException("Addons directory is file");
        if (Constants.SETTINGS_FILE.isDirectory())
            throw new RuntimeException("Settings file is directory");

        try {
            Class<?> clazz = Class.forName("org.eclipse.swt.widgets.Event");
            Object location = clazz.getProtectionDomain() != null
                    && clazz.getProtectionDomain().getCodeSource() != null
                            ? clazz.getProtectionDomain().getCodeSource().getLocation()
                            : "";
            throw new RuntimeException("SWT should not be loaded. Instead, it was loaded from " + location);
        } catch (ClassNotFoundException ignored) {
            loadSWTLibrary();
        }

        DisplayPumper displayPumper = new DisplayPumper();

        if (System.getProperty("os.name").toLowerCase().contains("mac")) {
            System.out.println("Attemting to force main thread");
            Executor executor;
            try {
                Class<?> dispatchClass = Class.forName("com.apple.concurrent.Dispatch");
                Object dispatchInstance = dispatchClass.getMethod("getInstance").invoke(null);
                executor = (Executor) dispatchClass.getMethod("getNonBlockingMainQueueExecutor")
                        .invoke(dispatchInstance);
            } catch (Throwable throwable) {
                throw new RuntimeException("Could not reflectively access Dispatch", throwable);
            }
            if (executor != null) {
                executor.execute(displayPumper);
            } else {
                throw new RuntimeException("Could not load executor");
            }
        } else {
            Thread pumpThread = new Thread(displayPumper);
            pumpThread.setName("Display Pumper");
            pumpThread.start();
        }
        while (!displayPumper.isReady())
            ;

        Display display = displayPumper.getDisplay();
        Shell shell = displayPumper.getShell();
        Splash splashScreen = new Splash(display);
        splashScreen.updateState(BootSequence.CHECKING_LIBRARIES);
        checkPackagedLibrary(splashScreen, "enjarify", Constants.ENJARIFY_VERSION,
                BootSequence.CHECKING_ENJARIFY, BootSequence.CLEANING_ENJARIFY, BootSequence.MOVING_ENJARIFY);
        checkPackagedLibrary(splashScreen, "Krakatau", Constants.KRAKATAU_VERSION,
                BootSequence.CHECKING_KRAKATAU, BootSequence.CLEANING_KRAKATAU, BootSequence.MOVING_KRAKATAU);

        try {
            if (!System.getProperty("os.name").toLowerCase().contains("linux")) {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            }
        } catch (Exception exception) { //Not important. No point notifying the user
        }

        Helios.main(args, shell, splashScreen);
        synchronized (displayPumper.getSynchronizer()) {
            displayPumper.getSynchronizer().wait();
        }
        System.exit(0);
    } catch (Throwable t) {
        displayError(t);
        System.exit(1);
    }
}

From source file:net.sf.jsignpdf.Signer.java

/**
 * Main./*from  ww  w  .  j a v  a2 s  . c  o  m*/
 * 
 * @param args
 */
public static void main(String[] args) {
    SignerOptionsFromCmdLine tmpOpts = null;

    if (args != null && args.length > 0) {
        tmpOpts = new SignerOptionsFromCmdLine();
        parseCommandLine(args, tmpOpts);
    }

    try {
        SSLInitializer.init();
    } catch (Exception e) {
        LOGGER.warn("Unable to re-configure SSL layer", e);
    }

    pkcs11ProviderName = PKCS11Utils
            .registerProvider(ConfigProvider.getInstance().getProperty("pkcs11config.path"));

    traceInfo();

    if (tmpOpts != null) {
        if (tmpOpts.isPrintVersion()) {
            System.out.println("JSignPdf version " + VERSION);
        }
        if (tmpOpts.isPrintHelp()) {
            printHelp();
        }
        if (tmpOpts.isListKeyStores()) {
            LOGGER.info(RES.get("console.keystores"));
            for (String tmpKsType : KeyStoreUtils.getKeyStores()) {
                System.out.println(tmpKsType);
            }
        }
        if (tmpOpts.isListKeys()) {
            final String[] tmpKeyAliases = KeyStoreUtils.getKeyAliases(tmpOpts);
            LOGGER.info(RES.get("console.keys"));
            // list certificate aliases in the keystore
            for (String tmpCert : tmpKeyAliases) {
                System.out.println(tmpCert);
            }
        }
        if (ArrayUtils.isNotEmpty(tmpOpts.getFiles())
                || (!StringUtils.isEmpty(tmpOpts.getInFile()) && !StringUtils.isEmpty(tmpOpts.getOutFile()))) {
            signFiles(tmpOpts);
        } else {
            final boolean tmpCommand = tmpOpts.isPrintVersion() || tmpOpts.isPrintHelp()
                    || tmpOpts.isListKeyStores() || tmpOpts.isListKeys();
            if (!tmpCommand) {
                // no valid command provided - print help and exit
                printHelp();
                exit(EXIT_CODE_NO_COMMAND);
            }
        }
        exit(0);
    } else {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            System.err.println("Can't set Look&Feel.");
        }
        SignPdfForm tmpForm = new SignPdfForm(WindowConstants.EXIT_ON_CLOSE);
        tmpForm.pack();
        GuiUtils.center(tmpForm);
        tmpForm.setVisible(true);
    }
}