Example usage for com.jgoodies.looks.plastic PlasticLookAndFeel setPlasticTheme

List of usage examples for com.jgoodies.looks.plastic PlasticLookAndFeel setPlasticTheme

Introduction

In this page you can find the example usage for com.jgoodies.looks.plastic PlasticLookAndFeel setPlasticTheme.

Prototype

public static void setPlasticTheme(PlasticTheme theme) 

Source Link

Document

Sets the theme for colors and fonts used by the Plastic L&F.

After setting the theme, you need to re-install the Look&Feel, as well as update the UI's of any previously created components - just as if you'd change the Look&Feel.

Usage

From source file:jsattrak.gui.LookAndFeelJDialog.java

License:Open Source License

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

    //LafChanger.changeLaf(parent, "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
    try {//from w ww  . j a  v  a 2  s .  c  o  m
        PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
        PlasticLookAndFeel.setTabStyle("Metal"); // makes tabes look much better
        UIManager.setLookAndFeel(new PlasticLookAndFeel());

        SwingUtilities.updateComponentTreeUI(parent); // apply look and feel over current L&F (otherwise nimbus shows up in correctly)
    } catch (Exception ex) {
    }
}

From source file:jsattrak.gui.LookAndFeelJDialog.java

License:Open Source License

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

    // LafChanger.changeLaf(parent, "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
    try {//  w  ww .  j  av a 2 s. com
        PlasticLookAndFeel.setPlasticTheme(new ExperienceGreen());
        PlasticLookAndFeel.setTabStyle("Metal"); // makes tabes look much better
        UIManager.setLookAndFeel(new PlasticLookAndFeel());

        SwingUtilities.updateComponentTreeUI(parent); // apply look and feel over current L&F (otherwise nimbus shows up in correctly)
    } catch (Exception ex) {
    }
}

From source file:jsattrak.gui.LookAndFeelJDialog.java

License:Open Source License

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed

    //LafChanger.changeLaf(parent, "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
    try {// w w w  .ja  v a  2  s . c o m
        PlasticLookAndFeel.setPlasticTheme(new Silver());
        PlasticLookAndFeel.setTabStyle("Metal"); // makes tabes look much better
        UIManager.setLookAndFeel(new PlasticLookAndFeel());

        SwingUtilities.updateComponentTreeUI(parent); // apply look and feel over current L&F (otherwise nimbus shows up in correctly)
    } catch (Exception ex) {
    }
}

From source file:net.littlelite.jurpedemo.frames.AbstractJurpeMain.java

License:Open Source License

/**
 * Set Look And Feel/*from  w w  w . jav  a  2  s.c o  m*/
 * 
 * @param n
 */
protected void setLookAndFeel(JurpeLookAndFeel n) {
    String laf = "";

    switch (n) {
    case XPLATFORM:
        laf = UIManager.getCrossPlatformLookAndFeelClassName();
        break;
    case SYSTEM:
        laf = UIManager.getSystemLookAndFeelClassName();
        break;
    case WINDOWS:
        laf = "com.jgoodies.looks.windows.WindowsLookAndFeel";
        break;
    case METAL:
        laf = "javax.swing.plaf.metal.MetalLookAndFeel";
        MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
        break;
    case OCEAN:
        laf = "javax.swing.plaf.metal.MetalLookAndFeel";
        try {
            MetalLookAndFeel.class.getMethod("getCurrentTheme", (Class[]) null);
            MetalLookAndFeel.setCurrentTheme(
                    (MetalTheme) Class.forName("javax.swing.plaf.metal.OceanTheme").newInstance());
        } catch (Exception e) {
            MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
        }
        break;
    case PLASTIC:
        PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_METAL_VALUE);
        PlasticLookAndFeel.setPlasticTheme(new SkyKrupp());
        laf = "com.jgoodies.looks.plastic.PlasticLookAndFeel";
        break;
    case PLASTICXP:
        PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_METAL_VALUE);
        PlasticLookAndFeel.setPlasticTheme(new ExperienceBlue());
        laf = "com.jgoodies.looks.plastic.PlasticXPLookAndFeel";
        break;
    case LOOKS:
        PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_DEFAULT_VALUE);
        PlasticLookAndFeel.setPlasticTheme(new Silver());
        laf = "com.jgoodies.looks.plastic.Plastic3DLookAndFeel";
        break;
    default:
        laf = UIManager.getSystemLookAndFeelClassName();
        break;
    }

    try {
        UIManager.setLookAndFeel(laf);
        SwingUtilities.updateComponentTreeUI(this);
        this.validate();
    } catch (ClassNotFoundException cnfe) {
        this.announce("Unknown Look And Feel: " + laf, true);
    } catch (UnsupportedLookAndFeelException ulafe) {
        this.announce("Unsupported Look And Feel: " + laf, true);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
    }
}

From source file:net.pms.newgui.LooksFrame.java

License:Open Source License

static void initializeLookAndFeel() {
    if (lookAndFeelInitialized) {
        return;/*from   w  w w.  j ava  2 s  .  c o m*/
    }

    LookAndFeel selectedLaf = null;
    if (Platform.isWindows()) {
        try {
            selectedLaf = (LookAndFeel) Class.forName("com.jgoodies.looks.windows.WindowsLookAndFeel")
                    .newInstance();
        } catch (Exception e) {
            selectedLaf = new PlasticLookAndFeel();
        }
    } else if (System.getProperty("nativelook") == null && !Platform.isMac()) {
        selectedLaf = new PlasticLookAndFeel();
    } else {
        try {
            String systemClassName = UIManager.getSystemLookAndFeelClassName();
            // workaround for Gnome
            try {
                String gtkLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
                Class.forName(gtkLAF);

                if (systemClassName.equals("javax.swing.plaf.metal.MetalLookAndFeel")) {
                    systemClassName = gtkLAF;
                }
            } catch (ClassNotFoundException ce) {
                logger.error("Error loading GTK look and feel: ", ce);
            }

            logger.trace("Choosing Java look and feel: " + systemClassName);
            UIManager.setLookAndFeel(systemClassName);
        } catch (Exception e1) {
            selectedLaf = new PlasticLookAndFeel();
            logger.error("Error while setting native look and feel: ", e1);
        }
    }

    if (selectedLaf instanceof PlasticLookAndFeel) {
        PlasticLookAndFeel.setPlasticTheme(PlasticLookAndFeel.createMyDefaultTheme());
        PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_DEFAULT_VALUE);
        PlasticLookAndFeel.setHighContrastFocusColorsEnabled(false);
    } else if (selectedLaf != null && selectedLaf.getClass() == MetalLookAndFeel.class) {
        MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
    }

    // Work around caching in MetalRadioButtonUI
    JRadioButton radio = new JRadioButton();
    radio.getUI().uninstallUI(radio);
    JCheckBox checkBox = new JCheckBox();
    checkBox.getUI().uninstallUI(checkBox);

    if (selectedLaf != null) {
        try {
            UIManager.setLookAndFeel(selectedLaf);
        } catch (UnsupportedLookAndFeelException e) {
            logger.warn("Can't change look and feel", e);
        }
    }

    lookAndFeelInitialized = true;
}

From source file:net.sf.nmedit.nomad.core.NomadLoader.java

License:Open Source License

private void initLookAndFeel(String lafClassName, String themeClassName, String defaultLafOnPlatform) {
    EnumSet<Platform.OS> defaultLafPlatforms = EnumSet.noneOf(Platform.OS.class);
    {/*  ww w.j  a  va2s.c o m*/
        // remove whitespace + lowercase
        defaultLafOnPlatform = defaultLafOnPlatform.replaceAll("\\s", "").toLowerCase();
        // split comma separated list
        String[] dlop = defaultLafOnPlatform.split(",");
        // check items
        for (String s : dlop) {
            if (s.equals("all")) {
                // on all platforms
                defaultLafPlatforms.addAll(EnumSet.allOf(Platform.OS.class));
                break;
            } else if (s.equals("mac")) {
                defaultLafPlatforms.add(Platform.OS.MacOSFlavor);
            } else if (s.equals("unix")) {
                defaultLafPlatforms.add(Platform.OS.UnixFlavor);
            } else if (s.equals("windows")) {
                defaultLafPlatforms.add(Platform.OS.WindowsFlavor);
            }
        }
    }

    // jgoodies specific properties

    PlasticLookAndFeel.setTabStyle(PlasticLookAndFeel.TAB_STYLE_METAL_VALUE);
    //UIManager.put(Options.POPUP_DROP_SHADOW_ENABLED_KEY, Boolean.FALSE);
    Options.setPopupDropShadowEnabled(false);
    Options.setUseNarrowButtons(true);

    //UIManager.put(Options.PLASTIC_MENU_FONT_KEY, new FontUIResource("Verdana", Font.PLAIN, 9));
    //PlasticLookAndFeel.setFontPolicy(FontPolicies.getDefaultWindowsPolicy());
    /*
            UIManager.put("MenuItem.margin", new InsetsUIResource(2,2,1,2));
            UIManager.put("Menu.margin", new InsetsUIResource(1,2,1,2));
            */
    // set the metal theme

    if (defaultLafPlatforms.contains(Platform.flavor())) {
        // use default LAF on current platform

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Throwable e) {
            Log log = LogFactory.getLog(getClass());
            log.warn("could not set look and feel theme", e);

        }

        if (Platform.isFlavor(Platform.OS.MacOSFlavor)) {
            System.setProperty("apple.laf.useScreenMenuBar", "true");
        }

    } else {
        // use LAF setting

        MetalTheme theme = null;
        if (themeClassName != null) {
            try {
                theme = (MetalTheme) Class.forName(themeClassName).newInstance();
                UIManager.put("Plastic.theme", themeClassName);

                if (theme instanceof PlasticTheme) {
                    PlasticLookAndFeel.setPlasticTheme((PlasticTheme) theme);
                    // PlasticLookAndFeel.setTabStyle(settings.getPlasticTabStyle());
                } else if (theme instanceof MetalTheme) {
                    MetalLookAndFeel.setCurrentTheme(theme);
                }

            } catch (Throwable e) {
                Log log = LogFactory.getLog(getClass());
                log.warn("could not set look and feel theme", e);
            }
        }
        // set the look and feel
        if (lafClassName != null) {
            try {
                LookAndFeel LAF = (LookAndFeel) Class.forName(lafClassName).newInstance();
                // it is very important to set the classloader  
                UIManager.getDefaults().put("ClassLoader", getClass().getClassLoader());
                UIManager.setLookAndFeel(LAF);
            } catch (Throwable e) {
                Log log = LogFactory.getLog(getClass());
                log.warn("could not set custom look and feel", e);
            }
        }
    }

}

From source file:org.deegree.igeo.desktop.IGeoDesktop.java

License:Open Source License

/**
 * @param processMonitor/*  ww  w  . j a  v a 2 s. c  o  m*/
 * 
 * 
 */
public IGeoDesktop(ProcessMonitor processMonitor) {
    super(processMonitor);
    try {
        String manager = System.getProperty("UIManager");
        if (manager != null) {
            UIManager.setLookAndFeel(manager);
        } else {
            // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
            Plastic3DLookAndFeel laf = new Plastic3DLookAndFeel();
            ExperienceBlue eb = new ExperienceBlue();
            PlasticLookAndFeel.setPlasticTheme(eb);
            UIManager.setLookAndFeel(laf);
        }
    } catch (Exception e) {
        LOG.logError("Could not load LookAndFeel: " + System.getProperty("UIManager"), e);
    }
}

From source file:org.deegree.igeo.desktop.IGeoDesktopEventHandler.java

License:Open Source License

static void actionPerformed(ApplicationContainer<Container> igeo, ActionEvent event) {
    Container container = igeo.getMainWndow();
    String eventName = null;//  ww w . jav a2  s  .  c o m
    if (event.getSource() instanceof JMenuItem) {
        eventName = ((JMenuItem) event.getSource()).getName();
    } else if (event.getSource() instanceof JButton) {
        eventName = ((JButton) event.getSource()).getName();
    } else {
        LOG.logError("could not determine name of event " + event);
        return;
    }
    if (eventName.startsWith("$class:")) {
        // if a event name starts with '$class:' the event name contains name of class
        // and a static method that shall be invoked. E.g.:
        // $class:de.lat-lon.igeodesktop.example.EventHandler#test
        IGeoDesktopEventHandler.invokeStaticEventHandler(igeo, eventName);
    } else if (eventName.startsWith("$module:")) {
        // if a event name starts with '$module:' the event name contains the name
        // of a registered module (or ApplicationContainer) and a method that shall be
        // invoked. E.g.: $module:MyModule#test or $module:ApplicationContainer#test
        IGeoDesktopEventHandler.invokeModuleEventHandler(igeo, eventName);
    } else if ("newproject".equals(eventName)) {
        IGeoDesktopEventHandler.openNewProject(igeo);
    } else if ("newprojectbyfile".equals(eventName)) {
        IGeoDesktopEventHandler.createNewProjectByDataFile(igeo);
    } else if ("open".equals(eventName)) {
        IGeoDesktopEventHandler.loadProject(igeo);
    } else if ("undo".equals(eventName)) {
        try {
            igeo.getCommandProcessor().undo();
        } catch (Exception e) {
            LOG.logError(e.getMessage(), e);
            throw new RuntimeException(Messages.getMessage(container.getLocale(), "$DG10047"));
        }
    } else if ("redo".equals(eventName)) {
        try {
            igeo.getCommandProcessor().redo();
        } catch (Exception e) {
            LOG.logError(e.getMessage(), e);
            throw new RuntimeException(Messages.getMessage(container.getLocale(), "$DG10048"));
        }
    } else if ("save".equals(eventName)) {
        try {
            if (igeo.isNew()) {
                IGeoDesktopEventHandler.saveProject(igeo);
            } else {
                IGeoDesktopEventHandler.saveProject(igeo, null);
            }
        } catch (Exception e) {
            LOG.logError(e.getMessage(), e);
            throw new RuntimeException(e);
        }
    } else if ("saveas".equals(eventName)) {
        try {
            IGeoDesktopEventHandler.saveProject(igeo);
        } catch (Exception e) {
            LOG.logError(e.getMessage(), e);
            throw new RuntimeException(
                    Messages.getMessage(container.getLocale(), "$DG10069", eventName, e.getMessage()));
        }
    } else if ("orderWindows".equals(eventName)) {
        Frame[] frames = Frame.getFrames();
        for (Frame fr : frames) {
            if (!"iGeoDesktop".equals(fr.getName())) {
                fr.toFront();
            }
        }
    } else if ("closeWindows".equals(eventName)) {
        Frame[] frames = Frame.getFrames();
        for (Frame fr : frames) {
            if (!"iGeoDesktop".equals(fr.getName())) {
                fr.dispose();
            }
        }
    } else if ("openLogger".equals(eventName)) {
        IGeoDesktopAppender.show();
    } else if ("login".equals(eventName)) {
        new LoginDialog(igeo);
    } else if ("logout".equals(eventName)) {
        igeo.logout();
    } else if ("addMapModel".equals(eventName)) {
        IGeoDesktopEventHandler.addMapModel(igeo);
    } else if ("removeMapModel".equals(eventName)) {
        IGeoDesktopEventHandler.removeMapModel(igeo);
    } else if ("openMapModel".equals(eventName)) {
        IGeoDesktopEventHandler.openMapModel(igeo);
    } else if ("setLookAndFeel".equals(eventName)) {
        LookAndFeelDialog laf = new LookAndFeelDialog(container);
        try {
            if (laf.confirmed()) {
                String look = laf.getLookAndfeel();
                Class<?> clzz = laf.getTheme();
                if (clzz != null) {
                    PlasticLookAndFeel cl = (PlasticLookAndFeel) Class.forName(look).newInstance();
                    PlasticLookAndFeel.setPlasticTheme((PlasticTheme) clzz.newInstance());
                    UIManager.setLookAndFeel(cl);
                } else {
                    UIManager.setLookAndFeel(look);
                }
            }
            SwingUtilities.updateComponentTreeUI(container);
        } catch (Exception e) {
            LOG.logError(e.getMessage());
        }
    } else if ("monitorCommands".equals(eventName)) {
        new CommandMonitorFrame(igeo);
    } else if ("iGeoDesktop:open help".equals(eventName)) {
        HelpFrame hf = HelpFrame.getInstance(new HelpManager(igeo));
        hf.setVisible(true);
    } else if ("iGeoDesktop:about".equals(eventName)) {
        new VersionDialog();
    }
}

From source file:org.formic.Installer.java

License:Open Source License

/**
 * Sets the look and feel./*from   w  w w  .j  a  v  a2 s. co  m*/
 */
private static void setLookAndFeel() {
    try {
        String laf = getString("wizard.laf", "com.jgoodies.looks.plastic.Plastic3DLookAndFeel");

        if (laf != null) {
            // plastic settings
            if (laf.startsWith("com.jgoodies.looks.plastic")) {
                String theme = getString("wizard.theme");
                if (theme != null) {
                    PlasticLookAndFeel.setPlasticTheme((PlasticTheme) Class.forName(theme).newInstance());
                }
            }

            UIManager.setLookAndFeel(laf);
        }
    } catch (Exception e) {
        throw new BuildException(e);
    }
}

From source file:org.jimcat.gui.SwingClient.java

License:Open Source License

/**
 * a call to this Methode will cause the Swing GUI to create a new Frame and
 * show it.//from   ww  w . j av a 2s.c  om
 */
public void startup() {
    // check if it hasn't been started yet
    if (started) {
        return;
    }

    SplashScreen.setProgressText("Loading Library");
    // create controles
    tagControl = new TagControl(this);
    imageControl = new ImageControl();
    albumControl = new AlbumControl(this);
    smartListControl = new SmartListControl(this);
    // create a new ViewControl
    viewControl = new ViewControl();

    started = true;

    SplashScreen.setProgressText("Creating GUI");
    // SplashScreen.fadeProgressBar();
    // Install LookAndFeel
    try {

        String theme = Configuration.getString("theme", DEFAULT_THEME);

        if (theme.equals("substance")) {
            UIManager.setLookAndFeel(new SubstanceLookAndFeel());
            SubstanceLookAndFeel.setSkin(new OfficeSilver2007Skin());
            UIManager.put(SubstanceLookAndFeel.NO_EXTRA_ELEMENTS, Boolean.TRUE);
            UIManager.put(LafWidget.ANIMATION_KIND, AnimationKind.NONE);
        } else if (theme.equals("jgoodies")) {
            PlasticLookAndFeel.setPlasticTheme(new SkyBlue());
            UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
        }

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }

    // Build up Frame - in right Thread
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            startupProcess();
        }
    });
}