Example usage for javax.swing UIManager put

List of usage examples for javax.swing UIManager put

Introduction

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

Prototype

public static Object put(Object key, Object value) 

Source Link

Document

Stores an object in the developer defaults.

Usage

From source file:org.eclipse.wb.internal.swing.laf.LafSupport.java

/**
 * Applies the selected LAF in Swing via UIManager.
 * //from  ww  w  . j  ava 2s .  c o m
 * @param lafInfo
 *          the {@link LafInfo} to be applied.
 */
public static void applySelectedLAF(final LafInfo lafInfo) {
    try {
        SwingUtils.runLaterAndWait(new RunnableEx() {
            public void run() throws Exception {
                LookAndFeel lookAndFeelInstance = lafInfo.getLookAndFeelInstance();
                UIManager.put("ClassLoader", lookAndFeelInstance.getClass().getClassLoader());
                UIManager.setLookAndFeel(lookAndFeelInstance);
            }
        });
    } catch (Throwable e) {
        DesignerPlugin.log(e);
    }
}

From source file:org.eclipse.wb.internal.swing.preferences.laf.LafPreferencePage.java

/**
 * Restores the {@link LookAndFeel} used before preview changed it.
 *//*  w w w .ja v a2s. c  om*/
private void restoreLookAndFeel() {
    ExecutionUtils.runLog(new RunnableEx() {
        public void run() throws Exception {
            UIManager.put("ClassLoader", m_currentLookAndFeel.getClass().getClassLoader());
            UIManager.setLookAndFeel(m_currentLookAndFeel);
        }
    });
}

From source file:org.eclipse.wb.internal.swing.preferences.laf.LafPreferencePage.java

/**
 * Updates the Swing preview part basing on selected LAF.
 *//*from w  w  w  .j  ava 2 s .co m*/
private void updatePreview0() {
    if (m_updatingPreview) {
        return;
    }
    m_updatingPreview = true;
    try {
        ExecutionUtils.runLog(new RunnableEx() {
            public void run() throws Exception {
                try {
                    m_previewGroup.getParent().setRedraw(false);
                    for (Control control : m_previewGroup.getChildren()) {
                        control.dispose();
                    }
                    LafInfo selectedLAF = getSelectedLAF();
                    if (selectedLAF == null) {
                        // nothing selected
                        return;
                    }
                    LookAndFeel lookAndFeel = selectedLAF.getLookAndFeelInstance();
                    m_previewGroup.getParent().layout(true);
                    UIManager.put("ClassLoader", lookAndFeel.getClass().getClassLoader());
                    UIManager.setLookAndFeel(lookAndFeel);
                    createPreviewArea(m_previewGroup);
                    m_previewGroup.getParent().layout(true);
                } finally {
                    m_previewGroup.getParent().setRedraw(true);
                }
            }
        });
    } finally {
        m_updatingPreview = false;
    }
}

From source file:org.eclipse.wb.internal.swing.preferences.laf.LafPreferencePage.java

/**
 * Creates {@link EmbeddedSwingComposite} with some Swing components to show it using different
 * LAFs./*from ww  w  . j ava  2  s.  c  o  m*/
 */
private void createPreviewArea(Group previewGroup) {
    try {
        LookAndFeel currentLookAndFeel = UIManager.getLookAndFeel();
        EmbeddedSwingComposite awtComposite = new EmbeddedSwingComposite(previewGroup, SWT.NONE) {
            @Override
            protected JComponent createSwingComponent() {
                // create the JRootPane
                JRootPane rootPane = new JRootPane();
                {
                    JMenuBar menuBar = new JMenuBar();
                    rootPane.setJMenuBar(menuBar);
                    {
                        JMenu mnFile = new JMenu(Messages.LafPreferencePage_previewFile);
                        menuBar.add(mnFile);
                        {
                            JMenuItem mntmNew = new JMenuItem(Messages.LafPreferencePage_previewNew);
                            mnFile.add(mntmNew);
                        }
                        {
                            JMenuItem mntmExit = new JMenuItem(Messages.LafPreferencePage_previewExit);
                            mnFile.add(mntmExit);
                        }
                    }
                    {
                        JMenu mnView = new JMenu(Messages.LafPreferencePage_previewView);
                        menuBar.add(mnView);
                        {
                            JMenuItem mntmCommon = new JMenuItem(Messages.LafPreferencePage_previewCommon);
                            mnView.add(mntmCommon);
                        }
                    }
                }
                GridBagLayout gridBagLayout = new GridBagLayout();
                gridBagLayout.columnWidths = new int[] { 0, 0, 0 };
                gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0 };
                gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0E-4 };
                gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0E-4 };
                rootPane.getContentPane().setLayout(gridBagLayout);
                {
                    JLabel lblLabel = new JLabel(Messages.LafPreferencePage_previewLabel);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 5, 5);
                    gbc.gridx = 0;
                    gbc.gridy = 0;
                    rootPane.getContentPane().add(lblLabel, gbc);
                }
                {
                    JButton btnPushButton = new JButton(Messages.LafPreferencePage_previewButton);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 5, 0);
                    gbc.gridx = 1;
                    gbc.gridy = 0;
                    rootPane.getContentPane().add(btnPushButton, gbc);
                }
                {
                    JComboBox comboBox = new JComboBox();
                    comboBox.setModel(new DefaultComboBoxModel(new String[] {
                            Messages.LafPreferencePage_previewCombo, "ComboBox Item 1", "ComboBox Item 2" }));
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 5, 5);
                    gbc.fill = GridBagConstraints.HORIZONTAL;
                    gbc.gridx = 0;
                    gbc.gridy = 1;
                    rootPane.getContentPane().add(comboBox, gbc);
                }
                {
                    JRadioButton rdbtnRadioButton = new JRadioButton(Messages.LafPreferencePage_previewRadio);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 5, 0);
                    gbc.gridx = 1;
                    gbc.gridy = 1;
                    rootPane.getContentPane().add(rdbtnRadioButton, gbc);
                }
                {
                    JCheckBox chckbxCheckbox = new JCheckBox(Messages.LafPreferencePage_previewCheck);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 0, 5);
                    gbc.gridx = 0;
                    gbc.gridy = 2;
                    rootPane.getContentPane().add(chckbxCheckbox, gbc);
                }
                {
                    JTextField textField = new JTextField();
                    textField.setText(Messages.LafPreferencePage_previewTextField);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.fill = GridBagConstraints.HORIZONTAL;
                    gbc.gridx = 1;
                    gbc.gridy = 2;
                    rootPane.getContentPane().add(textField, gbc);
                }
                return rootPane;
            }
        };
        awtComposite.populate();
        // restore current laf
        UIManager.put("ClassLoader", currentLookAndFeel.getClass().getClassLoader());
        UIManager.setLookAndFeel(currentLookAndFeel);
    } catch (Throwable e) {
        DesignerPlugin.log(e);
    }
}

From source file:org.ecoinformatics.seek.ecogrid.EcogridPreferencesTab.java

private void initButtonPanel() {

    // remember default button font
    final Font defaultUIMgrButtonFont = (Font) UIManager.get("Button.font");

    // now set our custom size, provided it's smaller than the default:
    int buttonFontSize = (defaultUIMgrButtonFont.getSize() < BUTTON_FONT_SIZE)
            ? defaultUIMgrButtonFont.getSize()
            : BUTTON_FONT_SIZE;//www  . j  a v a2  s .  c o  m

    final Font BUTTON_FONT = new Font(defaultUIMgrButtonFont.getFontName(), defaultUIMgrButtonFont.getStyle(),
            buttonFontSize);

    UIManager.put("Button.font", BUTTON_FONT);

    refreshButton = new JButton(new ServicesRefreshAction(
            StaticResources.getDisplayString("preferences.data.refresh", "Refresh"), this));
    refreshButton.setMinimumSize(EcogridPreferencesTab.BUTTONDIMENSION);
    refreshButton.setPreferredSize(EcogridPreferencesTab.BUTTONDIMENSION);
    refreshButton.setSize(EcogridPreferencesTab.BUTTONDIMENSION);
    // setMaximumSize was truncating label on osX. I don't know why. 
    // It seems about the same as how SearchUIJPanel does things. -derik
    //refreshButton.setMaximumSize(EcogridPreferencesTab.BUTTONDIMENSION);

    keepExistingCheckbox = new JCheckBox(
            StaticResources.getDisplayString("preferences.data.keepExistingSources", "Keep existing sources"));
    keepExistingCheckbox.setSelected(false);

    JPanel bottomPanel = new JPanel();

    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
    bottomPanel.add(refreshButton);
    bottomPanel.add(keepExistingCheckbox);

    newButtonPanel = new JPanel();
    newButtonPanel.setLayout(new BorderLayout());
    newButtonPanel.add(Box.createVerticalStrut(EcogridPreferencesTab.MARGINGSIZE), BorderLayout.NORTH);
    newButtonPanel.add(bottomPanel, BorderLayout.SOUTH);
    setButtonPanel(newButtonPanel);

    // restore default button font
    if (defaultUIMgrButtonFont != null) {
        UIManager.put("Button.font", defaultUIMgrButtonFont);
    }
}

From source file:org.executequery.util.LookAndFeelLoader.java

private void applyMacSettings() {

    if (UIUtils.isMac()) {

        String[] textComponents = { "TextField", "TextPane", "TextArea", "EditorPane", "PasswordField" };
        for (String textComponent : textComponents) {

            InputMap im = (InputMap) UIManager.get(textComponent + ".focusInputMap");
            im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), DefaultEditorKit.copyAction);
            im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK),
                    DefaultEditorKit.pasteAction);
            im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction);
        }//from  w  w  w  .j  av a 2 s  . c  o m

        if (UIUtils.isNativeMacLookAndFeel()) {

            UIManager.put("Table.gridColor", UIUtils.getDefaultBorderColour());
        }

    }

}

From source file:org.geworkbench.engine.ccm.DependencyManager.java

void checkDependency() {
    // in case other component does not like this
    Object oldSetting = UIManager.get("Button.defaultButtonFollowsFocus");
    UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
    JDialog dialog = optionPane.createDialog(null, "Dependency Checking Dialog");

    dialog.setVisible(true);//from  w  ww .  j a v  a  2  s. c  o  m
    Object obj = optionPane.getValue();
    UIManager.put("Button.defaultButtonFollowsFocus", oldSetting); // restore
    if (obj == null) {
        rollBack();
        return;
    }
    String selectedValue = (String) optionPane.getValue();
    if (selectedValue.equals("Continue")) {
        switch (changeFlag) {
        case LOAD:
            updateRequired();
            break;
        case UNLOAD:
            updateDependent();
            break;
        default:
            log.error("invalid flag independency manager");
        }
        return;
    } else { // if not "Continue"
        rollBack();
    }
}

From source file:org.lnicholls.galleon.gui.Galleon.java

private static void createAndShowGUI() {
    try {//from   ww w  .  j  av a 2s .c o  m
        System.setProperty("os.user.home", System.getProperty("user.home"));

        ArrayList errors = new ArrayList();
        Server.setup(errors);
        log = Server.setupLog("org.lnicholls.galleon.gui.Galleon", "GuiTrace", "GuiFile",
                Constants.GUI_LOG_FILE);
        // log = Logger.getLogger(Galleon.class.getName());
        printSystemProperties();

        UIManager.put("ClassLoader", (com.jgoodies.plaf.LookUtils.class).getClassLoader());
        UIManager.put("Application.useSystemFontSettings", Boolean.TRUE);
        Options.setGlobalFontSizeHints(FontSizeHints.MIXED2);
        Options.setDefaultIconSize(new Dimension(18, 18));
        try {
            UIManager.setLookAndFeel(
                    LookUtils.IS_OS_WINDOWS_XP ? "com.jgoodies.plaf.plastic.PlasticXPLookAndFeel"
                            : Options.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            Tools.logException(Galleon.class, e);
        }

        /*
         * mServerConfiguration = new ServerConfiguration(); if
         * (mConfigureDir != null) { log.info("Configuration Dir=" +
         * mConfigureDir.getAbsolutePath()); new
         * Configurator(mServerConfiguration).load(mAppManager,
         * mConfigureDir); } else new
         * Configurator(mServerConfiguration).load(mAppManager); mAddress =
         * mServerConfiguration.getIPAddress(); if (mAddress == null ||
         * mAddress.length() == 0) mAddress = "127.0.0.1";
         */
        log.info("Server address: " + mServerAddress);
        for (int i = 0; i < 100; i++) {
            try {
                mRegistry = LocateRegistry.getRegistry(mServerAddress, 1099 + i);
                String[] names = mRegistry.list();
                ServerControl serverControl = (ServerControl) mRegistry.lookup("serverControl");
                log.info("Found server at: " + mServerAddress + " on " + (1099 + i));
                break;
            } catch (Throwable ex) {
                if (log.isDebugEnabled())
                    Tools.logException(Galleon.class, ex);
            }
        }

        File directory = new File(System.getProperty("apps"));
        if (!directory.exists() || !directory.isDirectory()) {
            String message = "App Class Loader directory not found: " + System.getProperty("apps");
            InstantiationException exception = new InstantiationException(message);
            log.error(message, exception);
            throw exception;
        }

        File[] files = directory.listFiles(new FileFilter() {
            public final boolean accept(File file) {
                return !file.isDirectory() && !file.isHidden() && file.getName().toLowerCase().endsWith(".jar");
            }
        });
        ArrayList urls = new ArrayList();
        for (int i = 0; i < files.length; ++i) {
            try {
                URL url = files[i].toURI().toURL();
                urls.add(url);
                log.debug(url);
            } catch (Exception ex) {
                // should never happen
            }
        }

        directory = new File(System.getProperty("hme"));
        if (directory.exists()) {
            files = directory.listFiles(new FileFilter() {
                public final boolean accept(File file) {
                    return !file.isDirectory() && !file.isHidden()
                            && file.getName().toLowerCase().endsWith(".jar");
                }
            });
            for (int i = 0; i < files.length; ++i) {
                try {
                    URL url = files[i].toURI().toURL();
                    urls.add(url);
                    log.debug(url);
                } catch (Exception ex) {
                    // should never happen
                }
            }
        }

        File currentDirectory = new File(".");
        directory = new File(currentDirectory.getAbsolutePath() + "/../lib");
        // TODO Handle reloading; what if list changes?
        files = directory.listFiles(new FileFilter() {
            public final boolean accept(File file) {
                return !file.isDirectory() && !file.isHidden() && file.getName().toLowerCase().endsWith(".jar");
            }
        });
        for (int i = 0; i < files.length; ++i) {
            try {
                URL url = files[i].toURI().toURL();
                urls.add(url);
                log.debug(url);
            } catch (Exception ex) {
                // should never happen
            }
        }

        URLClassLoader classLoader = new URLClassLoader((URL[]) urls.toArray(new URL[0]));
        Thread.currentThread().setContextClassLoader(classLoader);

        mMainFrame = new MainFrame(Tools.getVersion());

        splashWindow.setVisible(false);
        mMainFrame.setVisible(true);

        /*
         * javax.swing.SwingUtilities.invokeLater(new Runnable() { public
         * void run() { mToGo.getRecordings(); } });
         */

        if (!isCurrentVersion()) {
            if (JOptionPane.showConfirmDialog(mMainFrame,
                    "A new version of Galleon is available. Do you want to download the latest version?",
                    "New Version", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                try {
                    BrowserLauncher.openURL("http://galleon.tv");
                } catch (Exception ex) {
                    Tools.logException(Galleon.class, ex);
                }
            }
        }

    } catch (Exception ex) {
        Tools.logException(Galleon.class, ex);
        System.exit(0);
    }
}

From source file:org.multibit.viewsystem.swing.action.ShowPreferencesSubmitAction.java

/**
 * Change preferences.//w ww . j ava 2s  .co m
 */
@Override
public void actionPerformed(ActionEvent event) {
    //        boolean feeValidationError = false;

    boolean wantToFireDataStructureChanged = false;

    try {
        if (mainFrame != null) {
            mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        }

        //            String updateStatusText = "";

        if (dataProvider != null) {
            controller.getModel().setUserPreference(CoreModel.PREVIOUS_UNDO_CHANGES_TEXT,
                    dataProvider.getPreviousUndoChangesText());

            //                String previousSendFee = dataProvider.getPreviousSendFee();
            //                String newSendFee = dataProvider.getNewSendFee();
            //                controller.getModel().setUserPreference(BitcoinModel.PREVIOUS_SEND_FEE, previousSendFee);
            //
            //                // Check fee is set.
            //                if (newSendFee == null || "".equals(newSendFee)) {
            //                    // Fee must be set validation error.
            //                    controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                    feeValidationError = true;
            //                    updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.aFeeMustBeSet");
            //                }
            //
            //                if (!feeValidationError) {
            //                    if (newSendFee.startsWith(ShowPreferencesPanel.UNPARSEABLE_FEE)) {
            //                        String newSendFeeTrimmed = newSendFee.substring(ShowPreferencesPanel.UNPARSEABLE_FEE.length() + 1);
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFeeTrimmed });
            //                    }
            //                }
            //                
            //                if (!feeValidationError) {
            //                    try {
            //                        // Check fee is a number.
            //                        BigInteger feeAsBigInteger = Utils.toNanoCoins(newSendFee);
            //
            //                        // Check fee is at least the minimum fee.
            //                        if (feeAsBigInteger.compareTo(BitcoinModel.SEND_MINIMUM_FEE) < 0) {
            //                            feeValidationError = true;
            //                            updateStatusText = controller.getLocaliser().getString(
            //                                    "showPreferencesPanel.feeCannotBeSmallerThanMinimumFee");
            //                        } else {
            //                            if (feeAsBigInteger.compareTo(BitcoinModel.SEND_MAXIMUM_FEE) >= 0) {
            //                                feeValidationError = true;
            //                                updateStatusText = controller.getLocaliser().getString(
            //                                        "showPreferencesPanel.feeCannotBeGreaterThanMaximumFee");
            //                            } else {
            //                                // Fee is ok.
            //                                controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, newSendFee);
            //                            }
            //                        }
            //                    } catch (NumberFormatException nfe) {
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFee });
            //                    } catch (ArithmeticException ae) {
            //                        // Recycle the old fee and set status message.
            //                        controller.getModel().setUserPreference(BitcoinModel.SEND_FEE, previousSendFee);
            //                        feeValidationError = true;
            //                        updateStatusText = controller.getLocaliser().getString("showPreferencesPanel.couldNotUnderstandFee",
            //                                new Object[] { newSendFee });
            //                    }
            //                }
        }

        // Disable language selection, uncomment to enable
        /*
             String previousLanguageCode = dataProvider.getPreviousUserLanguageCode();
             String newLanguageCode = dataProvider.getNewUserLanguageCode();
             controller.getModel().setUserPreference(CoreModel.PREVIOUS_USER_LANGUAGE_CODE, previousLanguageCode);
                
             if (previousLanguageCode != null && !previousLanguageCode.equals(newLanguageCode)) {
        // New language to set on model.
        controller.getModel().setUserPreference(CoreModel.USER_LANGUAGE_CODE, newLanguageCode);
        wantToFireDataStructureChanged = true;
             }
        */

        // Open URI - use dialog.
        String openUriDialog = dataProvider.getOpenUriDialog();
        if (openUriDialog != null) {
            controller.getModel().setUserPreference(BitcoinModel.OPEN_URI_SHOW_DIALOG, openUriDialog);
        }

        // Open URI - use URI.
        String openUriUseUri = dataProvider.getOpenUriUseUri();
        if (openUriUseUri != null) {
            controller.getModel().setUserPreference(BitcoinModel.OPEN_URI_USE_URI, openUriUseUri);
        }

        // Messaging servers
        boolean messagingServersHasChanged = false;
        String[] previousMessagingServerURLs = dataProvider.getPreviousMessagingServerURLs();
        String[] newMessagingServerURLs = dataProvider.getNewMessagingServerURLs();
        // newMessagingServerURLs might be NULL, and thus clear out the user preference.
        // So let's be explicit and say if no urls are set, we use the default.
        if (newMessagingServerURLs == null) {
            newMessagingServerURLs = CoreModel.DEFAULT_MESSAGING_SERVER_URLS; // not URL encoded but is okay as no strange characters.
        }
        if (!Arrays.equals(previousMessagingServerURLs, newMessagingServerURLs)) {
            messagingServersHasChanged = true;
            String s = StringUtils.join(newMessagingServerURLs, "|");
            controller.getModel().setUserPreference(CoreModel.MESSAGING_SERVERS, s);
        }

        // Font data.
        boolean fontHasChanged = false;
        String previousFontName = dataProvider.getPreviousFontName();
        String newFontName = dataProvider.getNewFontName();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_NAME, previousFontName);

        if (newFontName != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_NAME, newFontName);

            if (!newFontName.equals(previousFontName)) {
                fontHasChanged = true;
            }
        }

        String previousFontStyle = dataProvider.getPreviousFontStyle();
        String newFontStyle = dataProvider.getNewFontStyle();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_STYLE, previousFontStyle);

        if (newFontStyle != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_STYLE, newFontStyle);

            if (!newFontStyle.equals(previousFontStyle)) {
                fontHasChanged = true;
            }
        }

        String previousFontSize = dataProvider.getPreviousFontSize();
        String newFontSize = dataProvider.getNewFontSize();

        controller.getModel().setUserPreference(CoreModel.PREVIOUS_FONT_SIZE, previousFontSize);

        if (newFontSize != null) {
            controller.getModel().setUserPreference(CoreModel.FONT_SIZE, newFontSize);

            if (!newFontSize.equals(previousFontSize)) {
                fontHasChanged = true;
            }
        }

        // Look and feel.
        boolean lookAndFeelHasChanged = false;
        String previousLookAndFeel = dataProvider.getPreviousLookAndFeel();
        String newLookAndFeel = dataProvider.getNewLookAndFeel();

        controller.getModel().setUserPreference(CoreModel.LOOK_AND_FEEL, previousLookAndFeel);

        if (newLookAndFeel != null && (!newLookAndFeel.equals(previousLookAndFeel)
                && !newLookAndFeel.equals(UIManager.getLookAndFeel().getName()))) {
            controller.getModel().setUserPreference(CoreModel.LOOK_AND_FEEL, newLookAndFeel);

            lookAndFeelHasChanged = true;
        }
        /*
                    // Currency ticker.
                    boolean showTicker = dataProvider.getNewShowTicker();
                    boolean showBitcoinConvertedToFiat = dataProvider.getNewShowBitcoinConvertedToFiat();
                    boolean showCurrency = dataProvider.getNewShowCurrency();
                    boolean showRate = dataProvider.getNewShowRate();
                    boolean showBid = dataProvider.getNewShowBid();
                    boolean showAsk = dataProvider.getNewShowAsk();
                    boolean showExchange = dataProvider.getNewShowExchange();
                
                    boolean restartTickerTimer = false;
                
                    if (dataProvider.getPreviousShowCurrency() != showCurrency) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowBitcoinConvertedToFiat() != showBitcoinConvertedToFiat) {
        wantToFireDataStructureChanged = true;
        if (showBitcoinConvertedToFiat) {
            restartTickerTimer = true;
        }
                    } else if (dataProvider.getPreviousShowTicker() != showTicker || showTicker != dataProvider.isTickerVisible()) {
        wantToFireDataStructureChanged = true;
        if (showTicker) {
            restartTickerTimer = true;
        }
                    } else if (dataProvider.getPreviousShowRate() != showRate) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowBid() != showBid) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowAsk() != showAsk) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } else if (dataProvider.getPreviousShowExchange() != showExchange) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    } 
                
                    controller.getModel().setUserPreference(ExchangeModel.TICKER_SHOW, Boolean.valueOf(showTicker).toString());
                    controller.getModel().setUserPreference(ExchangeModel.SHOW_BITCOIN_CONVERTED_TO_FIAT,
                      Boolean.valueOf(showBitcoinConvertedToFiat).toString());
                
                    String columnsToShow = "";
                    if (showCurrency)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_CURRENCY;
                    if (showRate)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_LAST_PRICE;
                    if (showBid)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_BID;
                    if (showAsk)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_ASK;
                    if (showExchange)
        columnsToShow = columnsToShow + " " + TickerTableModel.TICKER_COLUMN_EXCHANGE;
                
                    if ("".equals(columnsToShow)) {
        // A user could just switch all the columns off in the settings
        // so
        // put a 'none' in the list of columns
        // this is to stop the default columns appearing.
        columnsToShow = TickerTableModel.TICKER_COLUMN_NONE;
                    }
                    controller.getModel().setUserPreference(ExchangeModel.TICKER_COLUMNS_TO_SHOW, columnsToShow);
                
                    String previousExchange1 = dataProvider.getPreviousExchange1();
                    String newExchange1 = dataProvider.getNewExchange1();
                    if (newExchange1 != null && !newExchange1.equals(previousExchange1)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE, newExchange1);
        ExchangeData newExchangeData = new ExchangeData();
        newExchangeData.setShortExchangeName(newExchange1);
        this.exchangeController.getModel().getShortExchangeNameToExchangeMap().put(newExchange1, newExchangeData);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousCurrency1 = dataProvider.getPreviousCurrency1();
                    String newCurrency1 = dataProvider.getNewCurrency1();
                    if (newCurrency1 != null && !newCurrency1.equals(previousCurrency1)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY, newCurrency1);
        String newCurrencyCode = newCurrency1;
        if (ExchangeData.BITCOIN_CHARTS_EXCHANGE_NAME.equals(newExchange1)) {
            // Use only the last three characters - the currency code.
             if (newCurrency1.length() >= 3) {
                newCurrencyCode = newCurrency1.substring(newCurrency1.length() - 3);
            }
        }
        try {
            CurrencyConverter.INSTANCE.setCurrencyUnit(CurrencyUnit.of(newCurrencyCode));
        } catch ( org.joda.money.IllegalCurrencyException e) {
            e.printStackTrace();
        }
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousShowSecondRow = Boolean.valueOf(dataProvider.getPreviousShowSecondRow()).toString();
                    String newShowSecondRow = Boolean.valueOf(dataProvider.getNewShowSecondRow()).toString();
                    if (newShowSecondRow != null && !newShowSecondRow.equals(previousShowSecondRow)) {
        // New show second row is set on model.
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW, newShowSecondRow);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousExchange2 = dataProvider.getPreviousExchange2();
                    String newExchange2 = dataProvider.getNewExchange2();
                    if (newExchange2 != null && !newExchange2.equals(previousExchange2)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE, newExchange2);
        ExchangeData newExchangeData = new ExchangeData();
        newExchangeData.setShortExchangeName(newExchange2);
        this.exchangeController.getModel().getShortExchangeNameToExchangeMap().put(newExchange2, newExchangeData);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                
                    String previousCurrency2 = dataProvider.getPreviousCurrency2();
                    String newCurrency2 = dataProvider.getNewCurrency2();
                    if (newCurrency2 != null && !newCurrency2.equals(previousCurrency2)) {
        controller.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_CURRENCY, newCurrency2);
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                    }
                            
                    String previousOerApicode = dataProvider.getPreviousOpenExchangeRatesApiCode();
                    String newOerApiCode = dataProvider.getNewOpenExchangeRatesApiCode();
                    if (newOerApiCode != null && !newOerApiCode.equals(previousOerApicode)) {
        wantToFireDataStructureChanged = true;
        restartTickerTimer = true;
                
        controller.getModel().setUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE, newOerApiCode);
                    }
        */
        // Can undo.
        controller.getModel().setUserPreference(CoreModel.CAN_UNDO_PREFERENCES_CHANGES, "true");
        /*
                    if (restartTickerTimer) {
        // Reinitialise the currency converter.
        CurrencyConverter.INSTANCE.initialise(controller);
                
        // Cancel any existing timer.
        if (mainFrame.getTickerTimer1() != null) {
            mainFrame.getTickerTimer1().cancel();
        }
        if (mainFrame.getTickerTimer2() != null) {
            mainFrame.getTickerTimer2().cancel();
        }                // Start ticker timer.
        Timer tickerTimer1 = new Timer();
        mainFrame.setTickerTimer1(tickerTimer1);
                
        TickerTimerTask tickerTimerTask1 = new TickerTimerTask(this.exchangeController, mainFrame, true);
        tickerTimerTask1.createExchangeObjects(controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE));
        mainFrame.setTickerTimerTask1(tickerTimerTask1);
                
        tickerTimer1.schedule(tickerTimerTask1, 0, TickerTimerTask.DEFAULT_REPEAT_RATE);
                
        boolean showSecondRow = Boolean.TRUE.toString().equals(
                controller.getModel().getUserPreference(ExchangeModel.TICKER_SHOW_SECOND_ROW));
                
        if (showSecondRow) {
            Timer tickerTimer2 = new Timer();
            mainFrame.setTickerTimer2(tickerTimer2);
                
            TickerTimerTask tickerTimerTask2 = new TickerTimerTask(this.exchangeController, mainFrame, false);
            tickerTimerTask2.createExchangeObjects(controller.getModel().getUserPreference(
                    ExchangeModel.TICKER_SECOND_ROW_EXCHANGE));
            mainFrame.setTickerTimerTask2(tickerTimerTask2);
                
            tickerTimer2.schedule(tickerTimerTask2, TickerTimerTask.TASK_SEPARATION, TickerTimerTask.DEFAULT_REPEAT_RATE);
        }
                    }
        */
        if (messagingServersHasChanged) {
            // TODO: Maybe something here so messaging servers are updated and go live immediately?
            // Currently servers are set here in class SendRequest:
            /*
                    public void setMessage(CoinSparkMessagePart [] MessageParts,String [] DeliveryServers)
            */

        }

        if (fontHasChanged) {
            wantToFireDataStructureChanged = true;
        }

        if (lookAndFeelHasChanged) {
            try {
                if (CoreModel.SYSTEM_LOOK_AND_FEEL.equals(newLookAndFeel)) {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } else {
                    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                        if (newLookAndFeel.equalsIgnoreCase(info.getName())) {
                            UIManager.setLookAndFeel(info.getClassName());
                            break;
                        }
                    }
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (UnsupportedLookAndFeelException e) {
                e.printStackTrace();
            }
        }

        Font newFont = dataProvider.getSelectedFont();
        if (newFont != null) {
            UIManager.put("ToolTip.font", newFont);
        }

        if (wantToFireDataStructureChanged || lookAndFeelHasChanged) {
            ColorAndFontConstants.init();
            FontSizer.INSTANCE.initialise(controller);
            HelpContentsPanel.clearBrowser();

            // Switch off blinks.
            this.bitcoinController.getModel().setBlinkEnabled(false);

            try {
                controller.fireDataStructureChanged();
                SwingUtilities.updateComponentTreeUI(mainFrame);
            } finally {
                // Switch blinks back on.
                this.bitcoinController.getModel().setBlinkEnabled(true);
            }
        }
    } finally {
        if (mainFrame != null) {
            mainFrame.setCursor(Cursor.getDefaultCursor());
        }
    }
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Sets the default font for all Swing components.
 * /* ww  w .jav  a2s .  c o m*/
 * @param f
 *            the f
 */
public static void setUIFont(FontUIResource f) {
    Enumeration<Object> keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof FontUIResource) {
            UIManager.put(key, f);
        }
    }
}