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:org.vpac.grisu.client.view.swing.mainPanel.Grisu.java

/**
 * Launches this application/*from  w  ww . j  ava2 s.  com*/
 */
public static void main(String[] args) {

    if ((args.length > 0) && (Arrays.binarySearch(args, "--debug") >= 0)) {
        Level lvl = Level.toLevel("debug");
        Logger.getRootLogger().setLevel(lvl);
    }

    Shibboleth.initDefaultSecurityProvider();

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

            Toolkit tk = Toolkit.getDefaultToolkit();
            tk.addAWTEventListener(WindowSaver.getInstance(), AWTEvent.WINDOW_EVENT_MASK);

            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception e) {
                myLogger.debug("Could not set OS look & feel.");
            }

            try {
                CertificateFiles.copyCACerts(false);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            myLogger.debug("Starting login dialog.");
            LoginDialog ld = new LoginDialog();
            ld.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
            ld.setVisible(true);

            if (ld.userCancelledLogin()) {
                myLogger.debug("User cancelled login dialog.");
                System.exit(0);
            }

            final Grisu application = new Grisu();
            application.serviceInterface = ld.getServiceInterface();
            myLogger.debug("Removing login dialog.");
            ld.dispose();

            myLogger.debug("Creating splash screen.");
            final LoginSplashScreen lss = new LoginSplashScreen();
            lss.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
            ApplicationStatusManager.getDefaultManager().addStatusListener(lss);
            lss.setVisible(true);

            new Thread() {
                @Override
                public void run() {
                    myLogger.debug("Creating progress bars.");

                    try {
                        application.em = new EnvironmentManager(application.serviceInterface);
                        GrisuRegistry.setServiceInterface(application.serviceInterface);
                        GrisuRegistry.setEnvironmentSnapshotValues(application.em);
                        application.em.initializeHistoryManager();
                        if (application.serviceInterface == null) {
                            myLogger.debug("Could not create/find service interface. Exiting.");
                            Utils.showErrorMessage(application.em, null, "startupError", null);
                            System.exit(1);
                        }
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        Utils.showErrorMessage(application.em, null, "startupError", e);
                        e.printStackTrace();
                        System.exit(1);
                    }

                    //            application.em.getFileManager().initAllFileSystemsInBackground();
                    //            application.em.buildInfoCacheInBackground();
                    //            application.em.getGlazedJobManagement().loadAllJobsInBackground();

                    //            ProgressDisplay pg_environment = new SwingProgressDisplay(application.getJFrame());
                    //            ProgressDisplay pg_submission = new SwingProgressDisplay(application.getJFrame());
                    ProgressDisplay pg_file_managementTransfer = new SwingProgressDisplay(
                            application.getJFrame());
                    ProgressDisplay pg_file_deletion = new SwingProgressDisplay(application.getJFrame());

                    //            EnvironmentManager.progressDisplay = pg_environment;
                    FileManagerTransferHelpers.progressDisplay = pg_file_managementTransfer;
                    FileManagerDeleteHelpers.progressDisplay = pg_file_deletion;

                    myLogger.debug("Setting application window visible.");
                    application.getJFrame().setVisible(true);

                    Thread.setDefaultUncaughtExceptionHandler(
                            new GrisuRuntimeExceptionHandler(application.getJFrame()));

                    ApplicationStatusManager.getDefaultManager().removeStatusListener(lss);
                    myLogger.debug("Removing splash screen.");
                    lss.dispose();

                    // now test whether there is a VO available
                    int availFqans = application.em.getAvailableFqans().length;
                    myLogger.debug("Number of avail Fqans: " + availFqans);
                    int usedFqans = application.em.getAllUsedFqans().size();
                    myLogger.debug("Number of used Fqans: " + usedFqans);
                    if (availFqans == 0) {
                        Utils.showErrorMessage(application.em, application.getJFrame(), "noVOs", null);
                    } else if (usedFqans == 0) {
                        Utils.showErrorMessage(application.em, application.getJFrame(), "noUsableVOs", null);
                    }

                }
            }.start();

        }
    });
}

From source file:org.vpac.grix.view.swing.Grix.java

/**
 * @param args/* ww  w.ja  v  a2  s  .c  o m*/
 */
public static void main(String[] args) {

    DependencyManager.showDownloadDialog = true;

    // Map<Dependency, String> dependencies = new HashMap<Dependency,
    // String>();

    // dependencies.put(Dependency.BOUNCYCASTLE, "jdk15-143");
    // dependencies.put(Dependency.ARCSGSI, "1.1");

    // DependencyManager.addDependencies(dependencies,
    // ArcsEnvironment.getArcsCommonJavaLibDirectory());

    JythonHelpers.setJythonCachedir();
    CoGProperties.getDefault().setProperty(CoGProperties.ENFORCE_SIGNING_POLICY, "false");

    java.security.Security.addProvider(new DefaultGridSecurityProvider());

    java.security.Security.setProperty("ssl.TrustManagerFactory.algorithm", "TrustAllCertificates");

    System.setSecurityManager(null);
    try {
        BouncyCastleTool.initBouncyCastle();
    } catch (ClassNotFoundException e1) {
        e1.printStackTrace();
    }

    final SplashScreen screen = new SplashScreen();
    screen.setVisible(true);

    try {
        CertificateFiles.copyCACerts(false);
    } catch (Exception e) {
        myLogger.error(e);
    }

    try {
        VomsesFiles.copyVomses(null);
    } catch (Exception e) {
        myLogger.error(e);
    }

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

            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            } catch (Exception e) {
                // try {
                // UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
                // } catch (Exception e1) {
                // // TODO Auto-generated catch block
                // //e1.printStackTrace();
                // }
            }
            try {
                // try whether the current proxy is a VomsProxy
                if (LocalProxy.getProxyFile().exists()) {

                    try {
                        VomsProxy vomsProxy = new VomsProxy(LocalProxy.getProxyFile());
                        LocalProxy.setDefaultProxy(vomsProxy);
                    } catch (NoVomsProxyException e) {
                        // TODO Auto-generated catch block
                        // e.printStackTrace();
                        myLogger.debug(e);
                        // thats ok, but make sure that there is a
                        // LocalProxy.getDefaultProxy() object
                        LocalProxy.setDefaultProxy(new GlobusProxy(LocalProxy.getProxyFile()));
                    }
                } else {
                    LocalProxy.setDefaultProxy(new GlobusProxy(LocalProxy.getProxyFile()));
                }
            } catch (IOException ioe) {
                myLogger.error(ioe);
                // ioe.printStackTrace();
            }

            try {

                Grix application = new Grix();
                application.initIcons();

                application.getJFrame().setVisible(true);

                screen.dispose();

                if (LocalProxy.getDefaultProxy().getStatus() == GridProxy.INITIALIZED) {
                    LocalVomses.getLocalVomses().getVomses();
                }
                LocalProxy.addStatusListener(LocalVomses.getLocalVomses());

                if (GlobusLocations.defaultLocations().getUserCert().exists()
                        && GlobusLocations.defaultLocations().getUserKey().exists()
                        && !LocalProxy.getDefaultProxy().isValid()
                        && "yes".equals(UserProperty.getProperty("CREATE_PROXY_AT_STARTUP"))) {
                    // display proxy window
                    application.getGridProxyDialog().setVisible(true);
                }

            } catch (Exception e) {

                JOptionPane.showMessageDialog(null, "Could not start Grix: " + e.getLocalizedMessage(),
                        "Startup error", JOptionPane.ERROR_MESSAGE);

                System.exit(1);
            }
        }
    });
}

From source file:org.wso2.carbon.device.mgt.iot.agent.firealarm.virtual.core.AgentManager.java

public void init() {

    // Read IoT-Server specific configurations from the 'deviceConfig.properties' file
    this.agentConfigs = AgentCoreOperations.readIoTServerConfigs();

    // Initialise IoT-Server URL endpoints from the configuration read from file
    AgentCoreOperations.initializeHTTPEndPoints();

    String analyticsPageContext = String.format(AgentConstants.DEVICE_ANALYTICS_PAGE_URL,
            agentConfigs.getDeviceId(), AgentConstants.DEVICE_TYPE);

    String controlPageContext = String.format(AgentConstants.DEVICE_DETAILS_PAGE_EP, AgentConstants.DEVICE_TYPE,
            agentConfigs.getDeviceId());

    this.deviceMgtAnalyticUrl = agentConfigs.getHTTPS_ServerEndpoint() + analyticsPageContext;
    this.deviceMgtControlUrl = agentConfigs.getHTTPS_ServerEndpoint() + controlPageContext;

    this.agentStatus = AgentConstants.NOT_REGISTERED;
    this.deviceName = this.agentConfigs.getDeviceName();

    this.pushInterval = this.agentConfigs.getDataPushInterval();
    this.networkInterface = AgentConstants.DEFAULT_NETWORK_INTERFACE;

    this.protocol = AgentConstants.DEFAULT_PROTOCOL;
    this.prevProtocol = protocol;

    Map<String, String> xmppIPPortMap = null;
    try {/*from w  ww . j  a  v a  2s .  c o m*/
        xmppIPPortMap = CommunicationUtils.getHostAndPort(agentConfigs.getXmppServerEndpoint());
    } catch (CommunicationHandlerException e) {
        log.error("XMPP Endpoint String - " + agentConfigs.getXmppServerEndpoint()
                + ", provided in the configuration file is invalid.");
    }

    String xmppServer = xmppIPPortMap.get("Host");
    int xmppPort = Integer.parseInt(xmppIPPortMap.get("Port"));

    String mqttTopic = String.format(AgentConstants.MQTT_SUBSCRIBE_TOPIC,
            agentManager.getAgentConfigs().getDeviceOwner(), agentManager.getAgentConfigs().getDeviceId());

    CommunicationHandler httpCommunicator = new HTTPCommunicationHandlerImpl();
    CommunicationHandler xmppCommunicator = new XMPPCommunicationHandlerImpl(xmppServer, xmppPort);
    CommunicationHandler mqttCommunicator = new MQTTCommunicationHandlerImpl(agentConfigs.getDeviceOwner(),
            agentConfigs.getDeviceId(), agentConfigs.getMqttBrokerEndpoint(), mqttTopic);

    agentCommunicator.put(AgentConstants.HTTP_PROTOCOL, httpCommunicator);
    agentCommunicator.put(AgentConstants.XMPP_PROTOCOL, xmppCommunicator);
    agentCommunicator.put(AgentConstants.MQTT_PROTOCOL, mqttCommunicator);

    try {
        interfaceList = new ArrayList<String>(CommunicationUtils.getInterfaceIPMap().keySet());
        protocolList = new ArrayList<String>(agentCommunicator.keySet());
    } catch (CommunicationHandlerException e) {
        log.error("An error occurred whilst retrieving all NetworkInterface-IP mappings");
    }

    try {
        // Set System L&F
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (UnsupportedLookAndFeelException e) {
        log.error("'UnsupportedLookAndFeelException' error occurred whilst initializing the" + " Agent UI.");
    } catch (ClassNotFoundException e) {
        log.error("'ClassNotFoundException' error occurred whilst initializing the Agent UI.");
    } catch (InstantiationException e) {
        log.error("'InstantiationException' error occurred whilst initializing the Agent UI.");
    } catch (IllegalAccessException e) {
        log.error("'IllegalAccessException' error occurred whilst initializing the Agent UI.");
    }

    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            agentUI = new AgentUI();
            agentUI.setVisible(true);
        }
    });

    agentCommunicator.get(protocol).connect();

}

From source file:org.wso2.carbon.device.mgt.iot.agent.firealarm.virtual.VirtualHardwareManager.java

public void init() {
    try {/* w  w  w.  j a  v  a 2  s  .co  m*/
        // Set System L&F for Device UI
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (UnsupportedLookAndFeelException e) {
        log.error("'UnsupportedLookAndFeelException' error occurred whilst initializing the" + " Agent UI.");
    } catch (ClassNotFoundException e) {
        log.error("'ClassNotFoundException' error occurred whilst initializing the Agent UI.");
    } catch (InstantiationException e) {
        log.error("'InstantiationException' error occurred whilst initializing the Agent UI.");
    } catch (IllegalAccessException e) {
        log.error("'IllegalAccessException' error occurred whilst initializing the Agent UI.");
    }
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            agentUI = new AgentUI();
            agentUI.setVisible(true);
        }
    });
    setAudioSequencer();
}

From source file:org.yccheok.jstock.gui.Utils.java

public static String setDefaultLookAndFeel() {
    try {//www  . j  a v a 2  s  . c  o  m
        String className = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(className);
        return className;
    } catch (java.lang.ClassNotFoundException | java.lang.InstantiationException
            | java.lang.IllegalAccessException | javax.swing.UnsupportedLookAndFeelException exp) {
        log.error(null, exp);
    }
    return null;
}

From source file:org.zaproxy.zap.GuiBootstrap.java

/**
 * Setups Swing's look and feel.//from w  w  w.  j  ava 2  s  .c o  m
 */
private void setupLookAndFeel() {
    try {
        // Set the systems Look and Feel
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        if (Constant.isMacOsX()) {
            OsXGui.setup();
        } else {
            // Set Nimbus LaF if available
            for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        }
    } catch (final UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException
            | IllegalAccessException e) {
        // handle exception
    }
}

From source file:phex.gui.common.LookAndFeelUtils.java

public static UIManager.LookAndFeelInfo[] getAvailableLAFs() {
    List<UIManager.LookAndFeelInfo> list = new ArrayList<UIManager.LookAndFeelInfo>();

    if (SystemUtils.IS_OS_MAC_OSX) {
        list.add(new UIManager.LookAndFeelInfo("Macintosh", UIManager.getSystemLookAndFeelClassName()));
    }/* w  ww  .  j av a  2s  . c  o m*/

    list.add(new UIManager.LookAndFeelInfo("PlasticXP (default)", Options.PLASTICXP_NAME));

    list.add(new UIManager.LookAndFeelInfo("Metal", "javax.swing.plaf.metal.MetalLookAndFeel"));
    //list.add( new UIManager.LookAndFeelInfo(
    //    "CDE/Motif", Options.EXT_MOTIF_NAME ) );

    if (SystemUtils.IS_OS_WINDOWS) {
        // This LAF will use the Java 1.4.2 avaiable XP look on XP systems
        list.add(
                new UIManager.LookAndFeelInfo("Windows", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"));
    }

    // The Java 1.4.2 available GTK+ LAF seems to be buggy and is not working
    // correctly together with the Swing UIDefault constants. Therefore we need
    // to wait with support of it
    Class gtkLAFClass;
    try {
        gtkLAFClass = Class.forName("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
    } catch (ClassNotFoundException e) {
        gtkLAFClass = null;
    }
    if (gtkLAFClass != null) {
        list.add(new UIManager.LookAndFeelInfo("GTK", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"));
    }

    UIManager.LookAndFeelInfo[] lafs = new UIManager.LookAndFeelInfo[list.size()];
    list.toArray(lafs);
    return lafs;
}

From source file:phex.gui.common.LookAndFeelUtils.java

/**
 * Returns the default LAF class name of the system.
 *///from  w  w w.j  a  va 2  s  . c  om
private static String getDefaultLAFClassName() {
    if (SystemUtils.IS_OS_MAC_OSX) {
        // set the look and feel to System
        return UIManager.getSystemLookAndFeelClassName();
    } else {
        // set the look and feel to Metal
        //lafClass = UIManager.getCrossPlatformLookAndFeelClassName();
        return Options.PLASTICXP_NAME;
    }
}

From source file:psidev.psi.mi.filemakers.xmlFlattener.XmlFlattenerGui.java

public static void main(String[] args) {

    /*//from ww  w .  j a  v a 2s  .c o m
     * Load look'n feel
     */
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e2) {
        log.warn("Cannot use System Look and Feel.");
    }

    XmlFlattenerGui f = new XmlFlattenerGui();

    Options options = new Options();

    Option option = new Option("mapping", true, "Mapping file");
    option.setRequired(false);
    options.addOption(option);

    option = new Option("xmlDocument", true, "XML document to parse");
    option.setRequired(false);
    options.addOption(option);
    option = new Option("schema", true, "Xsd schema, for instance data/MIF25.xsd");
    option.setRequired(false);
    options.addOption(option);
    option = new Option("o", true, "output tab delimited file");
    option.setRequired(false);
    options.addOption(option);
    option = new Option("validate", false,
            "validate the XML document (required to retrieved XML ids, e.g. with PSI-MI XML 1.0)");
    option.setRequired(false);
    options.addOption(option);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;

    try {
        // parse the command line arguments
        cmd = parser.parse(options, args, true);
    } catch (ParseException exp) {
        displayUsage(options);
        System.exit(1);
    }

    String mappingFileName = "";
    String schema = null;
    String xmlDocument = null;

    mappingFileName = cmd.getOptionValue("mapping");
    xmlDocument = cmd.getOptionValue("xmlDocument");
    schema = cmd.getOptionValue("schema");

    if (false == "".equals(mappingFileName)) {
        try {

            FileInputStream fin = new FileInputStream(mappingFileName);

            // Create XML encoder.
            XMLDecoder xdec = new XMLDecoder(fin);

            /* get mapping */
            TreeMapping treeMapping = (TreeMapping) xdec.readObject();

            /* tree */
            if (xmlDocument != null) {
                xmlDocument = xmlDocument.replaceAll("'", "");
                treeMapping.setDocumentURL(xmlDocument);
                log.info("xmlDocument: " + xmlDocument);
            }

            if (schema != null) {
                treeMapping.setSchemaURL(schema.replaceAll("'", ""));
            }

            if (cmd.hasOption("validate")) {
                log.info("XML document will be validated");
                ((XsdTreeStructImpl) f.treePanel.xsdTree).setValidateDocument(true);
            }

            ((XsdTreeStructImpl) f.treePanel.xsdTree).loadMapping(treeMapping);

            if (log.isErrorEnabled()) {
                log.error("Xml Parsing messages:");
                for (String error : ((XsdTreeStructImpl) f.treePanel.xsdTree).xmlErrorHandler.getErrors()) {
                    log.error(error);
                }
            }

            ((XsdTreeStructImpl) f.treePanel.xsdTree).loadMapping(treeMapping);
            f.treePanel.updatePreview();

            f.treePanel.setTreeSelectionListener();
            f.treePanel.setCellRenderer();
            f.treePanel.xsdTree.check();
            f.treePanel.reload();
            xdec.close();
            fin.close();
        } catch (Exception e) {

        }
    }
}

From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java

/**
 * Drag and Drop MITAB25 Converter./* w  w w.  j a v a2s.c  o  m*/
 */
public static void main(String[] args) throws FileNotFoundException {

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.error("Failed to change Look and Feel.", e);
    }

    // Create and set up the window.
    final JFrame frame = new javax.swing.JFrame("MITAB25 Converter");
    frame.setPreferredSize(new Dimension(400, 200));

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    frame.add(panel);

    addMenuBar(frame);

    Component label = new JLabel("Drag and drop your XML file(s) here");
    label.setPreferredSize(new Dimension(400, 200));
    label.setForeground(Color.red);
    panel.add(label);
    // Handle the dropped files
    PrintStream out = null; // could be System.out
    new DragAndDropComponent(out, panel, new FilesDroppedListener() {
        public void filesDropped(java.io.File[] files) {

            FilesProcessor processor = new FilesProcessor();
            processor.process(frame, files, expansionStrategy, postProcessorStrategy, aggregateSelectedFiles);
        }
    }); // end FileDrop.Listener

    // Set up the window.
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(100, 100, 50, 50); // the size of the frame is defined by its internal component.

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