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:com.brainflow.application.toplevel.Brainflow.java

private void initExceptionHandler() {
    LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer = new LookAndFeelFactory.UIDefaultsCustomizer() {
        public void customize(UIDefaults defaults) {
            ThemePainter painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
            defaults.put("OptionPaneUI", "com.jidesoft.plaf.basic.BasicJideOptionPaneUI");

            defaults.put("OptionPane.showBanner", Boolean.TRUE); // show banner or not. default is true
            //defaults.put("OptionPane.bannerIcon", JideIconsFactory.getImageIcon(JideIconsFactory.JIDE50));
            defaults.put("OptionPane.bannerFontSize", 13);
            defaults.put("OptionPane.bannerFontStyle", Font.BOLD);
            defaults.put("OptionPane.bannerMaxCharsPerLine", 60);
            defaults.put("OptionPane.bannerForeground",
                    painter != null ? painter.getOptionPaneBannerForeground() : null); // you should adjust this if banner background is not the default gradient paint
            defaults.put("OptionPane.bannerBorder", null); // use default border

            // set both bannerBackgroundDk and // set both bannerBackgroundLt to null if you don't want gradient
            defaults.put("OptionPane.bannerBackgroundDk",
                    painter != null ? painter.getOptionPaneBannerDk() : null);
            defaults.put("OptionPane.bannerBackgroundLt",
                    painter != null ? painter.getOptionPaneBannerLt() : null);
            defaults.put("OptionPane.bannerBackgroundDirection", Boolean.TRUE); // default is true

            // optionally, you can set a Paint object for BannerPanel. If so, the three UIDefaults related to banner background above will be ignored.
            defaults.put("OptionPane.bannerBackgroundPaint", null);

            defaults.put("OptionPane.buttonAreaBorder", BorderFactory.createEmptyBorder(6, 6, 6, 6));
            defaults.put("OptionPane.buttonOrientation", SwingConstants.RIGHT);
        }//from w ww.j  a  v  a 2 s.c  om
    };
    uiDefaultsCustomizer.customize(UIManager.getDefaults());

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            e.printStackTrace();
            JideOptionPane optionPane = new JideOptionPane(
                    "Click \"Details\" button to see more information ... ", JOptionPane.ERROR_MESSAGE,
                    JideOptionPane.CLOSE_OPTION);
            optionPane.setTitle("An " + e.getClass().getName() + " occurred in Brainflow : " + e.getMessage());

            JTextArea textArea = new JTextArea();
            StringWriter sw = new StringWriter();
            PrintWriter out = new PrintWriter(sw);
            e.printStackTrace(out);
            // Add string to end of text area
            textArea.append(sw.toString());
            textArea.setRows(10);
            optionPane.setDetails(new JScrollPane(textArea));
            JDialog dialog = optionPane.createDialog(brainFrame, "Warning");
            dialog.setResizable(true);
            dialog.pack();
            dialog.setVisible(true);
        }
    });

}

From source file:com.t3.client.TabletopTool.java

public static void main(String[] args) {
    if (MAC_OS_X) {
        // On OSX the menu bar at the top of the screen can be enabled at any time, but the
        // title (ie. name of the application) has to be set before the GUI is initialized (by
        // creating a frame, loading a splash screen, etc).  So we do it here.
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About TabletopTool...");
        System.setProperty("apple.awt.brushMetalLook", "true");
    }/*  ww w .j av  a 2s .c  om*/
    // Before anything else, create a place to store all the data
    try {
        AppUtil.getAppHome();
    } catch (Throwable t) {
        t.printStackTrace();

        // Create an empty frame so there's something to click on if the dialog goes in the background
        JFrame frame = new JFrame();
        SwingUtil.centerOnScreen(frame);
        frame.setVisible(true);

        String errorCreatingDir = "Error creating data directory";
        log.error(errorCreatingDir, t);
        JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
    verifyJavaVersion();

    configureLogging();

    // System properties
    System.setProperty("swing.aatext", "true");
    // System.setProperty("sun.java2d.opengl", "true");

    final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion());
    splash.showSplashScreen();

    // Protocol handlers
    // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?)
    RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory();
    factory.registerProtocol("asset", new AssetURLStreamHandler());
    URL.setURLStreamHandlerFactory(factory);

    MacroEngine.initialize();
    configureJide(); //TODO find out how to not call this twice without destroying error windows

    final Toolkit tk = Toolkit.getDefaultToolkit();
    tk.getSystemEventQueue().push(new T3EventQueue());

    // LAF
    try {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        configureJide();
        if (WINDOWS)
            LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);
        else
            LookAndFeelFactory.installJideExtension();
        if (MAC_OS_X) {
            macOSXicon();
        }
        menuBar = new AppMenuBar();
    } catch (Exception e) {
        TabletopTool.showError("msg.error.lafSetup", e);
        System.exit(1);
    }

    /**
     * This is a tweak that makes the Chinese version work better.
     * <p>
     * Consider reviewing <a
     * href="http://en.wikipedia.org/wiki/CJK_characters"
     * >http://en.wikipedia.org/wiki/CJK_characters</a> before making
     * changes. And http://www.scarfboy.com/coding/unicode-tool is also a
     * really cool site.
     */
    if (Locale.CHINA.equals(Locale.getDefault())) {
        // The following font name appears to be "Sim Sun".  It can be downloaded
        // from here:  http://fr.cooltext.com/Fonts-Unicode-Chinese
        Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12);
        FontUIResource fontRes = new FontUIResource(f);
        for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof FontUIResource)
                UIManager.put(key, fontRes);
        }
    }

    // Draw frame contents on resize
    tk.setDynamicLayout(true);

    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            initialize();
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    clientFrame.setVisible(true);
                    splash.hideSplashScreen();
                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            postInitialize();
                        }
                    });
                }
            });
        }
    });
    // new Thread(new HeapSpy()).start();
}

From source file:net.rptools.maptool.client.MapTool.java

public static void main(String[] args) {
    if (MAC_OS_X) {
        // On OSX the menu bar at the top of the screen can be enabled at any time, but the
        // title (ie. name of the application) has to be set before the GUI is initialized (by
        // creating a frame, loading a splash screen, etc).  So we do it here.
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About MapTool...");
        System.setProperty("apple.awt.brushMetalLook", "true");
    }//from  w  w w  . j  av  a2 s  .  c o m
    // Before anything else, create a place to store all the data
    try {
        AppUtil.getAppHome();
    } catch (Throwable t) {
        t.printStackTrace();

        // Create an empty frame so there's something to click on if the dialog goes in the background
        JFrame frame = new JFrame();
        SwingUtil.centerOnScreen(frame);
        frame.setVisible(true);

        String errorCreatingDir = "Error creating data directory";
        log.error(errorCreatingDir, t);
        JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
    verifyJavaVersion();

    configureLogging();

    // System properties
    System.setProperty("swing.aatext", "true");
    // System.setProperty("sun.java2d.opengl", "true");

    final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion());
    splash.showSplashScreen();

    // Protocol handlers
    // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?)
    RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory();
    factory.registerProtocol("asset", new AssetURLStreamHandler());
    URL.setURLStreamHandlerFactory(factory);

    final Toolkit tk = Toolkit.getDefaultToolkit();
    tk.getSystemEventQueue().push(new MapToolEventQueue());

    // LAF
    try {
        // If we are running under Mac OS X then save native menu bar look & feel components
        // Note the order of creation for the AppMenuBar, this specific chronology
        // allows the system to set up system defaults before we go and modify things.
        // That is, please don't move these lines around unless you test the result on windows and mac
        String lafname;
        if (MAC_OS_X) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            menuBar = new AppMenuBar();
            lafname = "net.rptools.maptool.client.TinyLookAndFeelMac";
            UIManager.setLookAndFeel(lafname);
            macOSXicon();
        }
        // If running on Windows based OS, CJK font is broken when using TinyLAF.
        //         else if (WINDOWS) {
        //            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        //            menuBar = new AppMenuBar();
        //         }
        else {
            lafname = "de.muntjak.tinylookandfeel.TinyLookAndFeel";
            UIManager.setLookAndFeel(lafname);
            menuBar = new AppMenuBar();
        }
        // After the TinyLAF library is initialized, look to see if there is a Default.theme
        // in our AppHome directory and load it if there is.  Unfortunately, changing the
        // search path for the default theme requires subclassing TinyLAF and because
        // we have both the original and a Mac version that gets cumbersome.  (Really
        // the Mac version should use the default and then install the keystroke differences
        // but what we have works and I'm loathe to go playing with it at 1.3b87 -- yes, 87!)
        File f = AppUtil.getAppHome("config");
        if (f.exists()) {
            File f2 = new File(f, "Default.theme");
            if (f2.exists()) {
                if (Theme.loadTheme(f2)) {
                    // re-install the Tiny Look and Feel
                    UIManager.setLookAndFeel(lafname);

                    // Update the ComponentUIs for all Components. This
                    // needs to be invoked for all windows.
                    //SwingUtilities.updateComponentTreeUI(rootComponent);
                }
            }
        }

        com.jidesoft.utils.Lm.verifyLicense("Trevor Croft", "rptools", "5MfIVe:WXJBDrToeLWPhMv3kI2s3VFo");
        LookAndFeelFactory.addUIDefaultsCustomizer(new LookAndFeelFactory.UIDefaultsCustomizer() {
            public void customize(UIDefaults defaults) {
                // Remove red border around menus
                defaults.put("PopupMenu.foreground", Color.lightGray);
            }
        });
        LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE);

        /****************************************************************************
         * For TinyLAF 1.3.04 this is how the color was changed for a
         * button.
         */
        // Theme.buttonPressedColor[Theme.style] = new ColorReference(Color.gray);

        /****************************************************************************
         * And this is how it's done in TinyLAF 1.4.0 (no idea about the
         * intervening versions).
         */
        Theme.buttonPressedColor = new SBReference(Color.GRAY, 0, -6, SBReference.SUB3_COLOR);

        configureJide();
    } catch (Exception e) {
        MapTool.showError("msg.error.lafSetup", e);
        System.exit(1);
    }

    /**
     * This is a tweak that makes the Chinese version work better.
     * <p>
     * Consider reviewing <a
     * href="http://en.wikipedia.org/wiki/CJK_characters"
     * >http://en.wikipedia.org/wiki/CJK_characters</a> before making
     * changes. And http://www.scarfboy.com/coding/unicode-tool is also a
     * really cool site.
     */
    if (Locale.CHINA.equals(Locale.getDefault())) {
        // The following font name appears to be "Sim Sun".  It can be downloaded
        // from here:  http://fr.cooltext.com/Fonts-Unicode-Chinese
        Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12);
        FontUIResource fontRes = new FontUIResource(f);
        for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof FontUIResource)
                UIManager.put(key, fontRes);
        }
    }

    // Draw frame contents on resize
    tk.setDynamicLayout(true);

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            initialize();
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    clientFrame.setVisible(true);
                    splash.hideSplashScreen();
                    EventQueue.invokeLater(new Runnable() {
                        public void run() {
                            postInitialize();
                        }
                    });
                }
            });
        }
    });
    // new Thread(new HeapSpy()).start();
}

From source file:com.t3.client.TabletopTool.java

private static final void configureJide() {
    com.jidesoft.utils.Lm.verifyLicense("T3 Team", "MapTool", "EOCG3JevAmlHo1o6OdcI80kvcf2wQkI2");

    LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer = new LookAndFeelFactory.UIDefaultsCustomizer() {
        @Override//from www. j  a va2s  . co  m
        public void customize(UIDefaults defaults) {
            ThemePainter painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
            defaults.put("OptionPaneUI", "com.jidesoft.plaf.basic.BasicJideOptionPaneUI");

            defaults.put("OptionPane.showBanner", Boolean.TRUE); // show banner or not. default is true
            defaults.put("OptionPane.bannerIcon", new ImageIcon(TabletopTool.class.getClassLoader()
                    .getResource("com/t3/client/image/tabletoptool_icon.png")));
            defaults.put("OptionPane.bannerFontSize", 13);
            defaults.put("OptionPane.bannerFontStyle", Font.BOLD);
            defaults.put("OptionPane.bannerMaxCharsPerLine", 60);
            defaults.put("OptionPane.bannerForeground",
                    painter != null ? painter.getOptionPaneBannerForeground() : null); // you should adjust this if banner background is not the default gradient paint
            defaults.put("OptionPane.bannerBorder", null); // use default border

            // set both bannerBackgroundDk and bannerBackgroundLt to null if you don't want gradient
            defaults.put("OptionPane.bannerBackgroundDk",
                    painter != null ? painter.getOptionPaneBannerDk() : null);
            defaults.put("OptionPane.bannerBackgroundLt",
                    painter != null ? painter.getOptionPaneBannerLt() : null);
            defaults.put("OptionPane.bannerBackgroundDirection", Boolean.TRUE); // default is true

            // optionally, you can set a Paint object for BannerPanel. If so, the three UIDefaults related to banner background above will be ignored.
            defaults.put("OptionPane.bannerBackgroundPaint", null);

            defaults.put("OptionPane.buttonAreaBorder", BorderFactory.createEmptyBorder(6, 6, 6, 6));
            defaults.put("OptionPane.buttonOrientation", SwingConstants.RIGHT);
        }
    };
    uiDefaultsCustomizer.customize(UIManager.getDefaults());

    //register cell editors and renderers
    for (TokenPropertyType tpt : TokenPropertyType.values())
        tpt.registerCellEditors();
    CellEditorManager.registerEditor(TokenPropertyType.class, new CellEditorFactory() {
        @Override
        public CellEditor create() {
            return new ListComboBoxCellEditor(TokenPropertyType.values());
        }
    });
}

From source file:net.rptools.maptool.client.MapTool.java

private static final void configureJide() {
    LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer = new LookAndFeelFactory.UIDefaultsCustomizer() {
        public void customize(UIDefaults defaults) {
            ThemePainter painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
            defaults.put("OptionPaneUI", "com.jidesoft.plaf.basic.BasicJideOptionPaneUI");

            defaults.put("OptionPane.showBanner", Boolean.TRUE); // show banner or not. default is true
            defaults.put("OptionPane.bannerIcon", new ImageIcon(MapTool.class.getClassLoader()
                    .getResource("net/rptools/maptool/client/image/maptool_icon.png")));
            defaults.put("OptionPane.bannerFontSize", 13);
            defaults.put("OptionPane.bannerFontStyle", Font.BOLD);
            defaults.put("OptionPane.bannerMaxCharsPerLine", 60);
            defaults.put("OptionPane.bannerForeground",
                    painter != null ? painter.getOptionPaneBannerForeground() : null); // you should adjust this if banner background is not the default gradient paint
            defaults.put("OptionPane.bannerBorder", null); // use default border

            // set both bannerBackgroundDk and bannerBackgroundLt to null if you don't want gradient
            defaults.put("OptionPane.bannerBackgroundDk",
                    painter != null ? painter.getOptionPaneBannerDk() : null);
            defaults.put("OptionPane.bannerBackgroundLt",
                    painter != null ? painter.getOptionPaneBannerLt() : null);
            defaults.put("OptionPane.bannerBackgroundDirection", Boolean.TRUE); // default is true

            // optionally, you can set a Paint object for BannerPanel. If so, the three UIDefaults related to banner background above will be ignored.
            defaults.put("OptionPane.bannerBackgroundPaint", null);

            defaults.put("OptionPane.buttonAreaBorder", BorderFactory.createEmptyBorder(6, 6, 6, 6));
            defaults.put("OptionPane.buttonOrientation", SwingConstants.RIGHT);
        }//from w w  w  . j a v a2  s .  c o m
    };
    uiDefaultsCustomizer.customize(UIManager.getDefaults());
}

From source file:forge.toolbox.FSkin.java

/**
 * Loads two sprites: the default (which should be a complete
 * collection of all symbols) and the preferred (which may be
 * incomplete).//from   ww  w.ja  v a2s  .  c o  m
 *
 * Font must be present in the skin folder, and will not
 * be replaced by default.  The fonts are pre-derived
 * in this method and saved in a HashMap for future access.
 *
 * Color swatches must be present in the preferred
 * sprite, and will not be replaced by default.
 *
 * Background images must be present in skin folder,
 * and will not be replaced by default.
 *
 * Icons, however, will be pulled from the two sprites. Obviously,
 * preferred takes precedence over default, but if something is
 * missing, the default picture is retrieved.
 */
public static void loadFull(final boolean onInit) {
    if (onInit) {
        // No need for this method to be loaded while on the EDT.
        FThreads.assertExecutedByEdt(false);

        // Preferred skin name must be called via loadLight() method,
        // which does some cleanup and init work.
        if (preferredName.isEmpty()) {
            loadLight("default", true);
        }
    }

    FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Processing image sprites: ", 7);

    // Grab and test various sprite files.
    final String defaultDir = ForgeConstants.DEFAULT_SKINS_DIR;
    final File f1 = new File(defaultDir + ForgeConstants.SPRITE_ICONS_FILE);
    final File f2 = new File(preferredDir + ForgeConstants.SPRITE_ICONS_FILE);
    final File f3 = new File(defaultDir + ForgeConstants.SPRITE_FOILS_FILE);
    final File f4 = new File(defaultDir + ForgeConstants.SPRITE_AVATARS_FILE);
    final File f5 = new File(preferredDir + ForgeConstants.SPRITE_AVATARS_FILE);
    final File f6 = new File(defaultDir + ForgeConstants.SPRITE_OLD_FOILS_FILE);
    final File f7 = new File(defaultDir + ForgeConstants.SPRITE_TROPHIES_FILE);
    final File f8 = new File(defaultDir + ForgeConstants.DRAFT_DECK_IMG_FILE);

    try {
        int p = 0;
        bimDefaultSprite = ImageIO.read(f1);
        FView.SINGLETON_INSTANCE.incrementSplashProgessBar(++p);
        bimPreferredSprite = ImageIO.read(f2);
        FView.SINGLETON_INSTANCE.incrementSplashProgessBar(++p);
        bimFoils = ImageIO.read(f3);
        FView.SINGLETON_INSTANCE.incrementSplashProgessBar(++p);
        bimOldFoils = f6.exists() ? ImageIO.read(f6) : ImageIO.read(f3);
        FView.SINGLETON_INSTANCE.incrementSplashProgessBar(++p);
        bimDefaultAvatars = ImageIO.read(f4);
        FView.SINGLETON_INSTANCE.incrementSplashProgessBar(++p);
        bimTrophies = ImageIO.read(f7);
        FView.SINGLETON_INSTANCE.incrementSplashProgessBar(++p);
        bimQuestDraftDeck = ImageIO.read(f8);

        if (f5.exists()) {
            bimPreferredAvatars = ImageIO.read(f5);
        }

        FView.SINGLETON_INSTANCE.incrementSplashProgessBar(++p);

        preferredH = bimPreferredSprite.getHeight();
        preferredW = bimPreferredSprite.getWidth();
    } catch (final Exception e) {
        System.err.println("FSkin$loadFull: Missing a sprite (default icons, " + "preferred icons, or foils.");
        e.printStackTrace();
    }

    // Initialize fonts
    if (onInit) { //set default font size only once onInit
        final Font f = UIManager.getDefaults().getFont("Label.font");
        if (f != null) {
            defaultFontSize = f.getSize();
        }
    }
    SkinFont.setBaseFont(GuiUtils.newFont(preferredDir + ForgeConstants.FONT_FILE));

    // Put various images into map (except sprite and splash).
    // Exceptions handled inside method.
    SkinIcon.setIcon(FSkinProp.BG_TEXTURE, preferredDir + ForgeConstants.TEXTURE_BG_FILE);
    SkinIcon.setIcon(FSkinProp.BG_MATCH, preferredDir + ForgeConstants.MATCH_BG_FILE);

    // Run through enums and load their coords.
    Colors.updateAll();
    for (final FSkinProp prop : FSkinProp.values()) {
        switch (prop.getType()) {
        case IMAGE:
            SkinImage.setImage(prop);
            break;
        case ICON:
            SkinIcon.setIcon(prop);
            break;
        case FOIL:
            setImage(prop, bimFoils);
            break;
        case OLD_FOIL:
            setImage(prop, bimOldFoils);
            break;
        case TROPHY:
            setImage(prop, bimTrophies);
            break;
        default:
            break;
        }
    }

    // Assemble avatar images
    assembleAvatars();

    // Images loaded; can start UI init.
    FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Creating display components.");
    loaded = true;

    // Clear references to buffered images
    bimDefaultSprite.flush();
    bimFoils.flush();
    bimOldFoils.flush();
    bimPreferredSprite.flush();
    bimDefaultAvatars.flush();
    bimQuestDraftDeck.flush();
    bimTrophies.flush();

    if (bimPreferredAvatars != null) {
        bimPreferredAvatars.flush();
    }

    bimDefaultSprite = null;
    bimFoils = null;
    bimOldFoils = null;
    bimPreferredSprite = null;
    bimDefaultAvatars = null;
    bimPreferredAvatars = null;
    bimQuestDraftDeck = null;
    bimTrophies = null;

    //establish encoding symbols
    final File dir = new File(ForgeConstants.CACHE_SYMBOLS_DIR);
    if (!dir.mkdir()) { //ensure symbols directory exists and is empty
        File[] files = dir.listFiles();
        assert files != null;
        for (final File file : files) {
            file.delete();
        }
    }

    addEncodingSymbol("W", FSkinProp.IMG_MANA_W);
    addEncodingSymbol("U", FSkinProp.IMG_MANA_U);
    addEncodingSymbol("B", FSkinProp.IMG_MANA_B);
    addEncodingSymbol("R", FSkinProp.IMG_MANA_R);
    addEncodingSymbol("G", FSkinProp.IMG_MANA_G);
    addEncodingSymbol("W/U", FSkinProp.IMG_MANA_HYBRID_WU);
    addEncodingSymbol("U/B", FSkinProp.IMG_MANA_HYBRID_UB);
    addEncodingSymbol("B/R", FSkinProp.IMG_MANA_HYBRID_BR);
    addEncodingSymbol("R/G", FSkinProp.IMG_MANA_HYBRID_RG);
    addEncodingSymbol("G/W", FSkinProp.IMG_MANA_HYBRID_GW);
    addEncodingSymbol("W/B", FSkinProp.IMG_MANA_HYBRID_WB);
    addEncodingSymbol("U/R", FSkinProp.IMG_MANA_HYBRID_UR);
    addEncodingSymbol("B/G", FSkinProp.IMG_MANA_HYBRID_BG);
    addEncodingSymbol("R/W", FSkinProp.IMG_MANA_HYBRID_RW);
    addEncodingSymbol("G/U", FSkinProp.IMG_MANA_HYBRID_GU);
    addEncodingSymbol("2/W", FSkinProp.IMG_MANA_2W);
    addEncodingSymbol("2/U", FSkinProp.IMG_MANA_2U);
    addEncodingSymbol("2/B", FSkinProp.IMG_MANA_2B);
    addEncodingSymbol("2/R", FSkinProp.IMG_MANA_2R);
    addEncodingSymbol("2/G", FSkinProp.IMG_MANA_2G);
    addEncodingSymbol("P/W", FSkinProp.IMG_MANA_PHRYX_W);
    addEncodingSymbol("P/U", FSkinProp.IMG_MANA_PHRYX_U);
    addEncodingSymbol("P/B", FSkinProp.IMG_MANA_PHRYX_B);
    addEncodingSymbol("P/R", FSkinProp.IMG_MANA_PHRYX_R);
    addEncodingSymbol("P/G", FSkinProp.IMG_MANA_PHRYX_G);
    for (int i = 0; i <= 20; i++) {
        addEncodingSymbol(String.valueOf(i), FSkinProp.valueOf("IMG_MANA_" + i));
    }
    addEncodingSymbol("X", FSkinProp.IMG_MANA_X);
    addEncodingSymbol("Y", FSkinProp.IMG_MANA_Y);
    addEncodingSymbol("Z", FSkinProp.IMG_MANA_Z);
    addEncodingSymbol("C", FSkinProp.IMG_CHAOS);
    addEncodingSymbol("Q", FSkinProp.IMG_UNTAP);
    addEncodingSymbol("S", FSkinProp.IMG_MANA_SNOW);
    addEncodingSymbol("T", FSkinProp.IMG_TAP);

    // Set look and feel after skin loaded
    FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Setting look and feel...");
    final ForgeLookAndFeel laf = new ForgeLookAndFeel();
    laf.setForgeLookAndFeel(Singletons.getView().getFrame());
}

From source file:brainflow.app.toplevel.BrainFlow.java

private void initExceptionHandler() {
    LookAndFeelFactory.UIDefaultsCustomizer uiDefaultsCustomizer = new LookAndFeelFactory.UIDefaultsCustomizer() {
        public void customize(UIDefaults defaults) {
            ThemePainter painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
            defaults.put("OptionPaneUI", "com.jidesoft.plaf.basic.BasicJideOptionPaneUI");

            defaults.put("OptionPane.showBanner", Boolean.TRUE); // show banner or not. default is true
            //defaults.put("OptionPane.bannerIcon", JideIconsFactory.getImageIcon(JideIconsFactory.JIDE50));
            defaults.put("OptionPane.bannerFontSize", 13);
            defaults.put("OptionPane.bannerFontStyle", Font.BOLD);
            defaults.put("OptionPane.bannerMaxCharsPerLine", 60);
            defaults.put("OptionPane.bannerForeground",
                    painter != null ? painter.getOptionPaneBannerForeground() : null); // you should adjust this if banner background is not the default gradient paint
            defaults.put("OptionPane.bannerBorder", null); // use default border

            // set both bannerBackgroundDk and // set both bannerBackgroundLt to null if you don't want gradient
            defaults.put("OptionPane.bannerBackgroundDk",
                    painter != null ? painter.getOptionPaneBannerDk() : null);
            defaults.put("OptionPane.bannerBackgroundLt",
                    painter != null ? painter.getOptionPaneBannerLt() : null);
            defaults.put("OptionPane.bannerBackgroundDirection", Boolean.TRUE); // default is true

            // optionally, you can set a Paint object for BannerPanel. If so, the three UIDefaults related to banner background above will be ignored.
            defaults.put("OptionPane.bannerBackgroundPaint", null);

            defaults.put("OptionPane.buttonAreaBorder", BorderFactory.createEmptyBorder(6, 6, 6, 6));
            defaults.put("OptionPane.buttonOrientation", SwingConstants.RIGHT);
        }/* ww w .  ja v a  2s. c  o m*/
    };
    uiDefaultsCustomizer.customize(UIManager.getDefaults());

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            e.printStackTrace();
            ExceptionDialog ed = new ExceptionDialog(e);
            JDialog dialog = ed.createDialog(brainFrame);
            dialog.setVisible(true);
        }
    });

}

From source file:edu.ku.brc.ui.UIRegistry.java

/**
 * Creates the initial font mapping from the base font size to the other sizes.
 * @param clazz the class of the component
 * @param baseFontArg the base font size
 *//*  w w w. j av  a  2  s .  com*/
protected static void adjustAllFonts(final Font oldBaseFont, final Font baseFontArg) {
    if (oldBaseFont != null && baseFontArg != null) {
        int fontSize = baseFontArg.getSize();
        int oldFontSize = oldBaseFont.getSize();
        String family = baseFontArg.getFamily();

        UIDefaults uiDefaults = UIManager.getDefaults();
        Enumeration<Object> e = uiDefaults.keys();
        while (e.hasMoreElements()) {
            Object key = e.nextElement();
            if (key.toString().endsWith(".font")) {
                FontUIResource fontUIRes = (FontUIResource) uiDefaults.get(key);
                if (fontSize != fontUIRes.getSize() || !family.equals(fontUIRes.getFamily())) {
                    UIManager.put(key, new FontUIResource(new Font(family, fontUIRes.getStyle(),
                            fontSize + (fontUIRes.getSize() - oldFontSize))));
                }
            }
        }
    }
}

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

/**
     * @param args the command line arguments
     * @throws Exception//from   w  ww  .j  a  v  a  2 s.c om
     */
    public static void main(String args[]) throws Exception {
        QLog.initial(args, 3);
        Locale.setDefault(Locales.getInstance().getLangCurrent());

        //?  ? , ? 
        final Thread tPager = new Thread(() -> {
            FAbout.loadVersionSt();
            String result = "";
            try {
                final URL url = new URL(PAGER_URL + "/qskyapi/getpagerdata?qsysver=" + FAbout.VERSION_);
                final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setRequestProperty("User-Agent", "Java bot");
                conn.connect();
                final int code = conn.getResponseCode();
                if (code == 200) {
                    try (BufferedReader in = new BufferedReader(
                            new InputStreamReader(conn.getInputStream(), "utf8"))) {
                        String inputLine;
                        while ((inputLine = in.readLine()) != null) {
                            result += inputLine;
                        }
                    }
                }
                conn.disconnect();
            } catch (Exception e) {
                System.err.println("Pager not enabled. " + e);
                return;
            }
            final Gson gson = GsonPool.getInstance().borrowGson();
            try {
                final Answer answer = gson.fromJson(result, Answer.class);
                forPager = answer;
                if (answer.getData().size() > 0) {
                    forPager.start();
                }
            } catch (Exception e) {
                System.err.println("Pager not enabled but working. " + e);
            } finally {
                GsonPool.getInstance().returnGson(gson);
            }
        });
        tPager.setDaemon(true);
        tPager.start();

        Uses.startSplash();
        //     plugins
        Uses.loadPlugins("./plugins/");
        //      ?.
        FLogin.logining(QUserList.getInstance(), null, true, 3, FLogin.LEVEL_ADMIN);
        Uses.showSplash();
        java.awt.EventQueue.invokeLater(() -> {
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
                        .getInstalledLookAndFeels()) {
                    System.out.println(info.getName());
                    /*Metal Nimbus CDE/Motif Windows   Windows Classic  //GTK+*/
                    if ("Windows".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
                if ("/".equals(File.separator)) {
                    final FontUIResource f = new FontUIResource(new Font("Serif", Font.PLAIN, 10));
                    final Enumeration<Object> keys = UIManager.getDefaults().keys();
                    while (keys.hasMoreElements()) {
                        final Object key = keys.nextElement();
                        final Object value = UIManager.get(key);
                        if (value instanceof FontUIResource) {
                            final FontUIResource orig = (FontUIResource) value;
                            final Font font1 = new Font(f.getFontName(), orig.getStyle(), f.getSize());
                            UIManager.put(key, new FontUIResource(font1));
                        }
                    }
                }
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                    | UnsupportedLookAndFeelException ex) {
            }
            try {
                form = new FAdmin();
                if (forPager != null) {
                    forPager.showData(false);
                } else {
                    form.panelPager.setVisible(false);
                }
                form.setVisible(true);
            } catch (Exception ex) {
                QLog.l().logger().error(" ? ??  . ", ex);
            } finally {
                Uses.closeSplash();
            }
        });
    }

From source file:com.pironet.tda.TDA.java

/**
 * set the ui SANS_SERIF for all tda stuff (needs to be done for create of objects)
 *
 * @param f the SANS_SERIF to user//from   w  w w.j  a  v a2 s  .  co  m
 */
private void setUIFont(FontUIResource f) {
    //
    // sets the default SANS_SERIF for all Swing components.
    // ex.
    //  setUIFont (new javax.swing.plaf.FontUIResource("Serif",Font.ITALIC,12));
    //
    Enumeration keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);
        if (value instanceof FontUIResource) {
            UIManager.put(key, f);
        }
    }
}