Example usage for javax.swing UIManager getDefaults

List of usage examples for javax.swing UIManager getDefaults

Introduction

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

Prototype

public static UIDefaults getDefaults() 

Source Link

Document

Returns the defaults.

Usage

From source file:org.nuclos.client.main.MainController.java

private Map<String, Map<String, Action>> getCommandMap() {
    HashMap<String, Map<String, Action>> res = new HashMap<String, Map<String, Action>>();
    HashMap<String, Action> mainController = new HashMap<String, Action>();

    /* that's too cumbersome:
    mainController.put(//from   ww  w .  j  av a  2  s.co  m
       "cmdChangePassword",
       new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
       cmdChangePassword();
    }
       });
     */

    mainController.put("cmdDirectHelp", cmdDirectHelp);
    mainController.put("cmdShowPersonalTasks", cmdShowPersonalTasks);
    mainController.put("cmdShowTimelimitTasks", cmdShowTimelimitTasks);
    mainController.put("cmdShowPersonalSearchFilters", cmdShowPersonalSearchFilters);
    mainController.put("cmdChangePassword", cmdChangePassword);
    mainController.put("cmdOpenSettings", cmdOpenSettings);
    mainController.put("cmdOpenManagementConsole", cmdOpenManagementConsole);
    //mainController.put("cmdOpenEntityWizard", cmdOpenEntityWizard);
    mainController.put("cmdOpenRelationEditor", cmdOpenRelationEditor);
    mainController.put("cmdOpenCustomComponentWizard", cmdOpenCustomComponentWizard);
    //mainController.put("cmdRefreshClientCaches", cmdRefreshClientCaches);
    mainController.put("cmdSelectAll", cmdSelectAll);
    mainController.put("cmdHelpContents", cmdHelpContents);
    mainController.put("cmdShowAboutDialog", cmdShowAboutDialog);
    mainController.put("cmdShowProjectReleaseNotes", cmdShowProjectReleaseNotes);
    mainController.put("cmdShowNuclosReleaseNotes", cmdShowNuclosReleaseNotes);
    mainController.put("cmdLogoutExit", cmdLogoutExit);
    mainController.put("cmdWindowClosing", cmdWindowClosing);
    mainController.put("cmdExecuteRport", cmdExecuteRport);

    for (Method m : getClass().getDeclaredMethods()) {
        if (m.getName().startsWith("cmd")) {
            Class<?>[] pt = m.getParameterTypes();
            if (pt.length == 0 || (pt.length == 1 && pt[0].isAssignableFrom(ActionEvent.class))) {
                final Method fm = m;
                Action a = new AbstractAction(m.getName()) {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        miDelegator(e, fm);
                    }
                };
                mainController.put(m.getName(), a);
            }
        }
    }

    res.put("MainController", mainController);

    HashMap<String, Action> clipboardUtils = new HashMap<String, Action>();
    clipboardUtils.put("cutAction", new ClipboardUtils.CutAction());
    clipboardUtils.put("copyAction", new ClipboardUtils.CopyAction());
    clipboardUtils.put("pasteAction", new ClipboardUtils.PasteAction());

    res.put("ClipboardUtils", clipboardUtils);

    HashMap<String, Action> dev = new HashMap<String, Action>();
    dev.put("jmsNotification", new AbstractAction("Test JMS notification") {

        @Override
        public void actionPerformed(ActionEvent e) {
            String s = JOptionPane.showInputDialog(getMainFrame(), "Topic: Message");
            if (s == null)
                return;
            String[] a = s.split(": *");
            if (a.length == 2) {
                // testFacadeRemote.testClientNotification(a[0], a[1]);
                throw new UnsupportedOperationException("TestFacade removed");
            } else {
                JOptionPane.showMessageDialog(getMainFrame(), "Wrong input format");
            }
        }
    });

    dev.put("webPrefs", new AbstractAction("Test Web Prefs-Access") {

        @Override
        public void actionPerformed(ActionEvent e) {
            String s = JOptionPane.showInputDialog(getMainFrame(), "Access-Path");
            if (s == null)
                return;
            try {
                Map<String, String> m = getWebAccessPrefs().getPrefsMap(s);
                StringBuilder sb = new StringBuilder();
                for (String k : m.keySet())
                    sb.append(k).append(": ").append(m.get(k)).append("\n");
                JOptionPane.showMessageDialog(getMainFrame(), sb.toString());
            } catch (CommonBusinessException e1) {
                Errors.getInstance().showExceptionDialog(getMainFrame(), e1);
            }
        }
    });

    dev.put("uiDefaults", new AbstractAction("UIDefaults") {

        @Override
        public void actionPerformed(ActionEvent e) {
            JFrame out = new JFrame("UIDefaults");
            out.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            out.getContentPane().setLayout(new BorderLayout());
            final UIDefTableModel mdl = new UIDefTableModel();
            final JTable contentTable = new JTable(mdl);
            JScrollPane sp = new JScrollPane(contentTable);
            out.getContentPane().add(sp, BorderLayout.CENTER);

            UIDefaults defs = UIManager.getDefaults();
            for (Object key : CollectionUtils.iterableEnum((defs.keys())))
                mdl.add(key.toString(), defs.get(key));
            mdl.sort();

            contentTable.getColumnModel().getColumn(1).setCellRenderer(new UIDefaultsRenderer());
            contentTable.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    int row = contentTable.rowAtPoint(e.getPoint());
                    mdl.forceValue(contentTable.convertRowIndexToModel(row));
                }
            });
            out.pack();
            out.setVisible(true);
        }
    });

    dev.put("checkJawin", new AbstractAction("Check Jawin") {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                SystemUtils.checkJawin();
                JOptionPane.showMessageDialog(Main.getInstance().getMainFrame(), "Jawin ok");
            } catch (Exception ex) {
                Errors.getInstance().showDetailedExceptionDialog(Main.getInstance().getMainFrame(), ex);
            }
        }
    });

    res.put("Dev", dev);

    return res;
}

From source file:org.opendatakit.briefcase.ui.CharsetConverterDialog.java

/**
 * Create the dialog.//from   w  w w  .  j  av  a 2 s . co  m
 */
public CharsetConverterDialog(Window owner) {
    super(owner, ModalityType.DOCUMENT_MODAL);
    setTitle(DIALOG_TITLE);
    setBounds(100, 100, 600, 530);
    getContentPane().setLayout(new BorderLayout());
    JPanel contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    GridBagLayout gbl_contentPanel = new GridBagLayout();
    contentPanel.setLayout(gbl_contentPanel);
    {
        JLabel lblNewLabel = new JLabel(SELECT_FILE_LABEL);
        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
        gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
        gbc_lblNewLabel.gridwidth = 2;
        gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0);
        gbc_lblNewLabel.gridx = 0;
        gbc_lblNewLabel.gridy = 0;
        contentPanel.add(lblNewLabel, gbc_lblNewLabel);
    }
    {
        tfFile = new JTextField();
        tfFile.setEditable(false);
        GridBagConstraints gbc_tfFile = new GridBagConstraints();
        gbc_tfFile.weightx = 1.0;
        gbc_tfFile.insets = new Insets(0, 0, 5, 5);
        gbc_tfFile.fill = GridBagConstraints.HORIZONTAL;
        gbc_tfFile.gridx = 0;
        gbc_tfFile.gridy = 1;
        contentPanel.add(tfFile, gbc_tfFile);
        tfFile.setColumns(10);
    }
    {
        JButton btnBrowse = new JButton(SELECT_FILE_BUTTON);
        btnBrowse.setActionCommand(BROWSE_COMMAND);
        btnBrowse.addActionListener(this);
        GridBagConstraints gbc_btnBrowse = new GridBagConstraints();
        gbc_btnBrowse.insets = new Insets(0, 0, 5, 0);
        gbc_btnBrowse.gridx = 1;
        gbc_btnBrowse.gridy = 1;
        contentPanel.add(btnBrowse, gbc_btnBrowse);
    }
    {
        JLabel lblEncoding = new JLabel(SELECT_SOURCE_ENCODING_LABEL);
        GridBagConstraints gbc_lblEncoding = new GridBagConstraints();
        gbc_lblEncoding.anchor = GridBagConstraints.WEST;
        gbc_lblEncoding.insets = new Insets(0, 0, 5, 5);
        gbc_lblEncoding.gridx = 0;
        gbc_lblEncoding.gridy = 2;
        contentPanel.add(lblEncoding, gbc_lblEncoding);
    }
    {
        listCharset = new JList<CharsetEntry>();
        listCharset.setVisibleRowCount(7);
        listCharset.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        GridBagConstraints gbc_cbCharset = new GridBagConstraints();
        gbc_cbCharset.gridwidth = 2;
        gbc_cbCharset.insets = new Insets(0, 0, 5, 0);
        gbc_cbCharset.fill = GridBagConstraints.BOTH;
        gbc_cbCharset.gridx = 0;
        gbc_cbCharset.gridy = 3;
        JScrollPane listScrollPane = new JScrollPane(listCharset);
        contentPanel.add(listScrollPane, gbc_cbCharset);
    }
    {
        JLabel lblPreview = new JLabel(PREVIEW_LABEL);
        GridBagConstraints gbc_lblPreview = new GridBagConstraints();
        gbc_lblPreview.anchor = GridBagConstraints.WEST;
        gbc_lblPreview.insets = new Insets(0, 0, 5, 5);
        gbc_lblPreview.gridx = 0;
        gbc_lblPreview.gridy = 4;
        contentPanel.add(lblPreview, gbc_lblPreview);
    }
    {
        JScrollPane scrollPane = new JScrollPane();
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.weighty = 1.0;
        gbc_scrollPane.weightx = 1.0;
        gbc_scrollPane.gridwidth = 2;
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 0;
        gbc_scrollPane.gridy = 5;
        contentPanel.add(scrollPane, gbc_scrollPane);
        {
            previewArea = new JTextArea();
            previewArea.setLineWrap(true);
            previewArea.setRows(10);
            previewArea.setFont(UIManager.getDefaults().getFont("Label.font").deriveFont(Font.PLAIN));
            previewArea.setEditable(false);
            scrollPane.setViewportView(previewArea);
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            cbOverride = new JCheckBox(REPLACE_EXISTING_FILE_LABEL);
            cbOverride.setSelected(false);
            buttonPane.add(cbOverride);
        }
        {
            JButton okButton = new JButton(CONVERT_BUTTON_LABEL);
            okButton.setActionCommand(CONVERT_COMMAND);
            okButton.addActionListener(this);
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            cancelButton = new JButton(CANCEL_BUTTON_LABEL);
            cancelButton.setActionCommand(CANCEL_COMMAND);
            cancelButton.addActionListener(this);
            buttonPane.add(cancelButton);
        }
    }
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.commonswing.ExceptionDialog.java

private void init() {
    messages = new Messages(getLocale(), SwingCommonModule.BUNDLE_NAME,
            ObjectUtilities.getClassLoader(SwingCommonModule.class));
    setModal(true);/* w ww  .j ava 2  s.  c o  m*/
    detailsAction = new DetailsAction();

    messageLabel = new JLabel();
    backtraceArea = new JTextArea();

    scroller = new JScrollPane(backtraceArea);
    scroller.setVisible(false);

    final JPanel detailPane = new JPanel();
    detailPane.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    final JLabel icon = new JLabel(UIManager.getDefaults().getIcon("OptionPane.errorIcon")); //$NON-NLS-1$
    icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    detailPane.add(icon, gbc);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.gridx = 1;
    gbc.gridy = 0;
    detailPane.add(messageLabel);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.SOUTH;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    detailPane.add(createButtonPane(), gbc);

    filler = new JPanel();
    filler.setPreferredSize(new Dimension(0, 0));
    filler.setBackground(Color.green);
    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.weighty = 5;
    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.gridwidth = 2;
    detailPane.add(filler, gbc);

    gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.weighty = 5;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.gridwidth = 2;
    detailPane.add(scroller, gbc);

    setContentPane(detailPane);
}

From source file:org.pentaho.reporting.tools.configeditor.ConfigDescriptionEditor.java

/**
 * Creates the statusbar for this frame. Use setStatus() to display text on the status bar.
 *
 * @return the status bar./*from ww w .  ja  v  a2s. c o  m*/
 */
protected JPanel createStatusBar() {
    final JPanel statusPane = new JPanel();
    statusPane.setLayout(new BorderLayout());
    statusPane.setBorder(BorderFactory.createLineBorder(UIManager.getDefaults().getColor("controlShadow"))); //$NON-NLS-1$
    statusHolder = new JLabel(" "); //$NON-NLS-1$
    statusPane.setMinimumSize(statusHolder.getPreferredSize());
    statusPane.add(statusHolder, BorderLayout.WEST);

    return statusPane;
}

From source file:org.pgptool.gui.ui.tools.UiUtils.java

public static void setLookAndFeel() {
    // NOTE: We doing it this way to prevent dead=locks that is sometimes
    // happens if do it in main thread
    Edt.invokeOnEdtAndWait(new Runnable() {
        @Override/*from   w w  w .  j av a  2  s .c  o  m*/
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                fixCheckBoxMenuItemForeground();
                fixFontSize();
            } catch (Throwable t) {
                log.error("Failed to set L&F", t);
            }
        }

        /**
         * In some cases (depends on OS theme) check menu item foreground is same as
         * bacground - thus it;'s invisible when cheked
         */
        private void fixCheckBoxMenuItemForeground() {
            UIDefaults defaults = UIManager.getDefaults();
            Color selectionForeground = defaults.getColor("CheckBoxMenuItem.selectionForeground");
            Color foreground = defaults.getColor("CheckBoxMenuItem.foreground");
            Color background = defaults.getColor("CheckBoxMenuItem.background");
            if (colorsDiffPercentage(selectionForeground, background) < 10) {
                // TODO: That doesn't actually affect defaults. Need to find out how to fix it
                defaults.put("CheckBoxMenuItem.selectionForeground", foreground);
            }
        }

        private int colorsDiffPercentage(Color c1, Color c2) {
            int diffRed = Math.abs(c1.getRed() - c2.getRed());
            int diffGreen = Math.abs(c1.getGreen() - c2.getGreen());
            int diffBlue = Math.abs(c1.getBlue() - c2.getBlue());

            float pctDiffRed = (float) diffRed / 255;
            float pctDiffGreen = (float) diffGreen / 255;
            float pctDiffBlue = (float) diffBlue / 255;

            return (int) ((pctDiffRed + pctDiffGreen + pctDiffBlue) / 3 * 100);
        }

        private void fixFontSize() {
            if (isJreHandlesScaling()) {
                log.info("JRE handles font scaling, won't change it");
                return;
            }
            log.info("JRE doesnt't seem to support font scaling");

            Toolkit toolkit = Toolkit.getDefaultToolkit();
            int dpi = toolkit.getScreenResolution();
            if (dpi == 96) {
                if (log.isDebugEnabled()) {
                    Font font = UIManager.getDefaults().getFont("TextField.font");
                    String current = font != null ? Integer.toString(font.getSize()) : "unknown";
                    log.debug(
                            "Screen dpi seem to be 96. Not going to change font size. Btw current size seem to be "
                                    + current);
                }
                return;
            }
            int targetFontSize = 12 * dpi / 96;
            log.debug("Screen dpi = " + dpi + ", decided to change font size to " + targetFontSize);
            setDefaultSize(targetFontSize);
        }

        private boolean isJreHandlesScaling() {
            try {
                JreVersion noNeedToScaleForVer = JreVersion.parseString("9");
                String jreVersionStr = System.getProperty("java.version");
                if (jreVersionStr != null) {
                    JreVersion curVersion = JreVersion.parseString(jreVersionStr);
                    if (noNeedToScaleForVer.compareTo(curVersion) <= 0) {
                        return true;
                    }
                }

                return false;
            } catch (Throwable t) {
                log.warn("Failed to see oif JRE can handle font scaling. Will assume it does. JRE version: "
                        + System.getProperty("java.version"), t);
                return true;
            }
        }

        public void setDefaultSize(int size) {
            Set<Object> keySet = UIManager.getLookAndFeelDefaults().keySet();
            Object[] keys = keySet.toArray(new Object[keySet.size()]);
            for (Object key : keys) {
                if (key != null && key.toString().toLowerCase().contains("font")) {
                    Font font = UIManager.getDefaults().getFont(key);
                    if (font != null) {
                        Font changedFont = font.deriveFont((float) size);
                        UIManager.put(key, changedFont);
                        Font doubleCheck = UIManager.getDefaults().getFont(key);
                        log.debug("Font size changed for " + key + ". From " + font.getSize() + " to "
                                + doubleCheck.getSize());
                    }
                }
            }
        }
    });
    log.info("L&F set");
}

From source file:org.tellervo.desktop.prefs.Prefs.java

private void initUIDefaults() {
    // UIDEFAULTS.putAll(UIManager.getDefaults());
    UIDefaults defaults = UIManager.getDefaults();
    // XXX: Even though Hashtable implements Map since
    // Java 1.2, UIDefaults is "special"... the Iterator
    // returned by UIDefaults keySet object does not return any
    // keys, and therefore Enumeration must be used instead - aaron
    Enumeration<?> e = defaults.keys();

    while (e.hasMoreElements()) {
        Object key = e.nextElement();
        Object value = defaults.get(key);

        // for some reason, java 1.6 seems to have some null values.
        if (value == null)
            continue;

        // log.debug("Saving UIDefault: " + key);
        UIDEFAULTS.put(key, value);//from w w w.  j ava2  s .c o  m
    }
}

From source file:org.tellervo.desktop.prefs.Prefs.java

/**
 * Loads any saved uidefaults preferences and installs them
 *//*w w w .  j  a  v a  2 s .  c o  m*/
private synchronized void installUIDefaultsPrefs() {
    Iterator<?> it = prefs.entrySet().iterator();
    UIDefaults uidefaults = UIManager.getDefaults();
    log.debug("iterating prefs");
    while (it.hasNext()) {
        @SuppressWarnings("rawtypes")
        Map.Entry entry = (Map.Entry) it.next();
        String prefskey = entry.getKey().toString();
        if (!prefskey.startsWith("uidefaults.") || prefskey.length() <= "uidefaults.".length())
            continue;
        String uikey = prefskey.substring("uidefaults.".length());
        Object object = uidefaults.get(uikey);
        log.debug("prefs property " + uikey + " " + object);
        installUIDefault(object.getClass(), prefskey, uikey);
    }
}

From source file:org.tellervo.desktop.prefs.Prefs.java

private void installUIDefault(Class<? extends Object> type, String prefskey, String uikey) {
    Object decoded = null;/* w w w .  ja  va 2 s.c  om*/
    String pref = prefs.getProperty(prefskey);
    if (pref == null) {
        log.warn("Preference '" + prefskey + "' held null value.");
        return;
    }
    if (Color.class.isAssignableFrom(type)) {
        decoded = Color.decode(pref);
    } else if (Font.class.isAssignableFrom(type)) {
        decoded = Font.decode(pref);
    } else {
        log.warn("Unsupported UIDefault preference type: " + type);
        return;
    }

    if (decoded == null) {
        log.warn("UIDefaults color preference '" + prefskey + "' was not decodable.");
        return;
    }

    UIDefaults uidefaults = UIManager.getDefaults();
    // if (uidefaults.contains(property)) {
    // NOTE: ok, UIDefaults object is strange. Not only does
    // it not implement the Map interface correctly, but entries
    // will not "stick". The entries must be first explicitly
    // removed, and then re-added - aaron
    log.debug("Removing UIDefaults key before overwriting: " + uikey);
    uidefaults.remove(uikey);
    // }

    if (Color.class.isAssignableFrom(type)) {
        uidefaults.put(uikey, new ColorUIResource((Color) decoded));
    } else {
        uidefaults.put(uikey, new FontUIResource((Font) decoded));
    }
}

From source file:org.trianacode.gui.hci.ApplicationFrame.java

/**
 * Initialise the application/* www  .j a  v a2 s. c o  m*/
 */
public static ApplicationFrame initTriana(String args[]) {
    // todo: this is crap, use andrew's UI stuff
    // Andrew Sept 2010: Done - 6 years on... :-)
    UIDefaults uiDefaults = UIManager.getDefaults();
    Object font = ((FontUIResource) uiDefaults.get("TextArea.font")).deriveFont((float) 11);

    Enumeration enumeration = uiDefaults.keys();
    while (enumeration.hasMoreElements()) {
        Object key = enumeration.nextElement();

        if (key.toString().endsWith("font")) {
            uiDefaults.put(key, font);
        }
    }

    String myOSName = Locations.os();
    if (myOSName.equals("windows")) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
        }
    } else {
        if (!myOSName.equals("osx")) {
            try {
                MetalLookAndFeel.setCurrentTheme(new OceanTheme());
                UIManager.setLookAndFeel(new MetalLookAndFeel());
            } catch (Exception e) {
            }
        }

    }

    ApplicationFrame app = new ApplicationFrame("Triana");
    app.init(args);

    return app;
}

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

/**
 * @param args the command line arguments
 *///from www  .  ja va  2  s .co  m
public static void main(String args[]) {
    /***********************************************************************
     * UI Manager initialization via JStockOptions.
     **********************************************************************/
    final JStockOptions jStockOptions = getJStockOptionsViaXML();

    // OSX menu bar at top.
    if (Utils.isMacOSX()) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("apple.awt.brushMetalLook", "true");
    }

    boolean uiManagerLookAndFeelSuccess = false;
    try {
        String lookNFeel = jStockOptions.getLooknFeel();
        if (null != lookNFeel) {
            UIManager.setLookAndFeel(lookNFeel);
            uiManagerLookAndFeelSuccess = true;
        }
    } catch (java.lang.ClassNotFoundException | java.lang.InstantiationException
            | java.lang.IllegalAccessException | javax.swing.UnsupportedLookAndFeelException exp) {
        log.error(null, exp);
    }

    if (!uiManagerLookAndFeelSuccess) {
        String className = Utils.setDefaultLookAndFeel();
        if (null != className) {
            final String lookNFeel = jStockOptions.getLooknFeel();
            // When jStockOptions.getLookNFeel returns null, it means we wish
            // to use system default value. Hence, don't overwrite the null value,
            // so that we can use the same jStockOptions, across different
            // platforms.
            if (lookNFeel != null) {
                jStockOptions.setLooknFeel(className);
            }
        }
    }

    /***********************************************************************
     * Ensure correct localization.
     **********************************************************************/
    // This global effect, should just come before anything else, 
    // after we get an instance of JStockOptions.
    Locale.setDefault(jStockOptions.getLocale());

    /***********************************************************************
     * Single application instance enforcement.
     **********************************************************************/
    if (false == AppLock.lock()) {
        final int choice = JOptionPane.showOptionDialog(null,
                MessagesBundle.getString("warning_message_running_2_jstock"),
                MessagesBundle.getString("warning_title_running_2_jstock"), JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE, null,
                new String[] { MessagesBundle.getString("yes_button_running_2_jstock"),
                        MessagesBundle.getString("no_button_running_2_jstock") },
                MessagesBundle.getString("no_button_running_2_jstock"));
        if (choice != JOptionPane.YES_OPTION) {
            System.exit(0);
            return;
        }
    }

    // Avoid "JavaFX IllegalStateException when disposing JFXPanel in Swing"
    // http://stackoverflow.com/questions/16867120/javafx-illegalstateexception-when-disposing-jfxpanel-in-swing
    Platform.setImplicitExit(false);

    // As ProxyDetector is affected by system properties
    // http.proxyHost, we are forced to initialized ProxyDetector right here,
    // before we manually change the system properties according to
    // JStockOptions.
    ProxyDetector.getInstance();

    /***********************************************************************
     * Apply large font if possible.
     **********************************************************************/
    if (jStockOptions.useLargeFont()) {
        java.util.Enumeration keys = UIManager.getDefaults().keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value != null && value instanceof javax.swing.plaf.FontUIResource) {
                javax.swing.plaf.FontUIResource fr = (javax.swing.plaf.FontUIResource) value;
                UIManager.put(key, new javax.swing.plaf.FontUIResource(
                        fr.deriveFont((float) fr.getSize2D() * (float) Constants.FONT_ENLARGE_FACTOR)));
            }
        }
    }

    /***********************************************************************
     * GA tracking.
     **********************************************************************/
    GA.trackAsynchronously("main");

    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            final JStock mainFrame = JStock.instance();

            // We need to first assign jStockOptions to mainFrame, as during
            // Utils.migrateXMLToCSVPortfolios, we will be accessing mainFrame's
            // jStockOptions.
            mainFrame.initJStockOptions(jStockOptions);

            mainFrame.init();
            mainFrame.setVisible(true);
            mainFrame.updateDividerLocation();
            mainFrame.requestFocusOnJComboBox();
        }
    });
}