Example usage for javax.swing.plaf ColorUIResource ColorUIResource

List of usage examples for javax.swing.plaf ColorUIResource ColorUIResource

Introduction

In this page you can find the example usage for javax.swing.plaf ColorUIResource ColorUIResource.

Prototype

public ColorUIResource(Color c) 

Source Link

Document

Constructs a ColorUIResource .

Usage

From source file:Main.java

public ColorUIResource getControlDarkShadow() {
    return new ColorUIResource(java.awt.Color.orange);
}

From source file:Main.java

public ColorUIResource getControl() {
    return new ColorUIResource(java.awt.Color.orange);
}

From source file:org.jdal.swing.ApplicationContextGuiFactory.java

public static void setPlasticLookAndFeel() {
    try {/* w  w  w . j  av a2s .  c o m*/
        UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
        UIManager.put("Table.gridColor", new ColorUIResource(Color.GRAY));
        UIManager.put("TableHeader.background", new ColorUIResource(220, 220, 220));

    } catch (UnsupportedLookAndFeelException e) {
        log.error(e);
    }
}

From source file:lcmc.LCMC.java

/** Create the GUI and show it. */
protected static void createAndShowGUI(final Container mainFrame) {
    final java.util.List<Object> buttonGradient = Arrays.asList(new Object[] { new Float(.3f), new Float(0f),
            new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND), new ColorUIResource(0xFFFFFF),
            new ColorUIResource(ClusterBrowser.BUTTON_PANEL_BACKGROUND) });
    final java.util.List<Object> checkboxGradient = Arrays.asList(
            new Object[] { new Float(.3f), new Float(0f), new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND),
                    new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND), new ColorUIResource(0xFFFFFF) });
    ToolTipManager.sharedInstance().setInitialDelay(TOOLTIP_INITIAL_DELAY);
    ToolTipManager.sharedInstance().setDismissDelay(TOOLTIP_DISMISS_DELAY);
    UIManager.put("TableHeader.background", Tools.getDefaultColor("DrbdMC.TableHeader"));
    UIManager.put("TableHeader.font", UIManager.getFont("Label.font"));
    UIManager.put("Button.gradient", buttonGradient);
    UIManager.put("Button.select", ClusterBrowser.PANEL_BACKGROUND);

    UIManager.put("CheckBox.gradient", checkboxGradient);
    UIManager.put("CheckBoxMenuItem.gradient", checkboxGradient);
    UIManager.put("RadioButton.gradient", checkboxGradient);
    UIManager.put("RadioButton.rollover", Boolean.TRUE);
    UIManager.put("RadioButtonMenuItem.gradient", checkboxGradient);
    UIManager.put("ScrollBar.gradient", buttonGradient);
    UIManager.put("ToggleButton.gradient", buttonGradient);

    UIManager.put("Menu.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("MenuItem.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("List.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("ComboBox.selectionBackground", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("OptionPane.background", ClusterBrowser.BUTTON_PANEL_BACKGROUND);
    UIManager.put("Panel.background", ClusterBrowser.PANEL_BACKGROUND);

    /* Create and set up the window. */
    Tools.getGUIData().setMainFrame(mainFrame);

    /* Display the window. */
    mainFrame.setSize(Tools.getDefaultInt("DrbdMC.width"), Tools.getDefaultInt("DrbdMC.height"));
    mainFrame.setVisible(true);/*w w w .j av a  2 s  .c  o  m*/
}

From source file:edu.ku.brc.ui.skin.SkinItem.java

/**
 * @param nm/*  ww w.  j a v a 2  s.  c o  m*/
 */
public void pushFG(final String nm) {
    if (fgColor != null) {
        if (cacheHash == null) {
            cacheHash = new Hashtable<String, Object>();
        }
        cacheHash.put(nm, UIManager.get(nm));
        UIManager.put(nm, new ColorUIResource(fgColor));
    }
}

From source file:edu.ku.brc.ui.skin.SkinItem.java

/**
 * /*w  w w  .  j av  a2s. co m*/
 */
public void register() {
    if (getFont() != null) {
        UIManager.put(name + '.' + "font", new FontUIResource(font));
    }
    if (bgColor != null) {
        UIManager.put(name + '.' + "bgcolor", new ColorUIResource(bgColor));
    }
    if (fgColor != null) {
        UIManager.put(name + '.' + "fgcolor", new ColorUIResource(fgColor));
    }
    if (getBGImage() != null) {
        UIManager.put(name + '.' + "bgimage", bgImage);
    }
}

From source file:lcmc.LCMC.java

/** Inits the application. */
protected static String initApp(final String[] args) {
    try {/*from ww w  .  j a  va2 s  .  com*/
        /* Metal */
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        MetalLookAndFeel.setCurrentTheme(new OceanTheme() {
            /** e.g. arrows on split pane... */
            protected ColorUIResource getPrimary1() {
                return new ColorUIResource(ClusterBrowser.STATUS_BACKGROUND);
            }

            /** unknown to me */
            protected ColorUIResource getPrimary2() {
                return new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND);
            }

            /** unknown to me */
            protected ColorUIResource getPrimary3() {
                return new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND);
            }

            /** Button and other borders. */
            protected ColorUIResource getSecondary1() {
                return new ColorUIResource(AppDefaults.BACKGROUND_DARK);
            }

            protected ColorUIResource getSecondary2() {
                return new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND);
            }

            /** Split pane divider. Line in the main menu. */
            protected ColorUIResource getSecondary3() {
                return new ColorUIResource(ClusterBrowser.PANEL_BACKGROUND);
            }
        });
    } catch (final Exception e) {
        /* ignore it then */
    }
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(final Thread t, final Throwable ex) {
            Tools.appError("uncaught exception", ex.toString(), (Exception) ex);
        }
    });
    float fps = 20.0f;
    final Options options = new Options();

    options.addOption("h", HELP_OP, false, "print this help");
    options.addOption(null, KEEP_HELPER_OP, false, "do not overwrite the lcmc-gui-helper program");
    options.addOption(null, RO_OP, false, "read only mode");
    options.addOption(null, OP_OP, false, "operator mode");
    options.addOption(null, ADMIN_OP, false, "administrator mode");
    options.addOption(null, OP_MODE_OP, true, "operating mode. <arg> can be:\n" + "ro - read only\n"
            + "op - operator\n" + "admin - administrator");
    options.addOption(null, NOLRM_OP, false, "do not show removed resources from LRM.");
    options.addOption(null, "auto", true, "for testing");
    options.addOption("v", VERSION_OP, false, "print version");
    options.addOption(null, AUTO_OP, true, "for testing");
    options.addOption(null, NO_UPGRADE_CHECK_OP, false, "disable upgrade check");
    options.addOption(null, NO_PLUGIN_CHECK_OP, false,
            "disable plugin check, DEPRECATED: there are no plugins");
    options.addOption(null, TIGHTVNC_OP, false, "enable tight vnc viewer");
    options.addOption(null, ULTRAVNC_OP, false, "enable ultra vnc viewer");
    options.addOption(null, REALVNC_OP, false, "enable real vnc viewer");
    options.addOption(null, BIGDRBDCONF_OP, false,
            "create one big drbd.conf, instead of many" + " files in drbd.d/ directory");
    options.addOption(null, STAGING_DRBD_OP, false, "enable more DRBD installation options");
    options.addOption(null, STAGING_PACEMAKER_OP, false, "enable more Pacemaker installation options");
    options.addOption(null, VNC_PORT_OFFSET_OP, true, "offset for port forwarding");
    options.addOption(null, SLOW_OP, false, "specify this if you have slow computer");
    options.addOption(null, RESTORE_MOUSE_OP, false, "for testing");
    options.addOption(null, SCALE_OP, true, "scale fonts and sizes of elements in percent (100)");
    options.addOption(null, ID_DSA_OP, true, "location of id_dsa file ($HOME/.ssh/id_dsa)");
    options.addOption(null, ID_RSA_OP, true, "location of id_rsa file ($HOME/.ssh/id_rsa)");
    options.addOption(null, KNOWN_HOSTS_OP, true, "location of known_hosts file ($HOME/.ssh/known_hosts)");
    options.addOption(null, OUT_OP, true, "where to redirect the standard out");
    options.addOption(null, DEBUG_OP, true, "debug level, 0 - none, 3 - all");
    options.addOption("c", CLUSTER_OP, true, "define a cluster");
    final Option hostOp = new Option("h", HOST_OP, true, "define a cluster, used with --cluster option");
    hostOp.setArgs(10000);
    options.addOption(hostOp);
    options.addOption(null, SUDO_OP, false, "whether to use sudo, used with --cluster option");
    options.addOption(null, USER_OP, true, "user to use with sudo, used with --cluster option");
    options.addOption(null, PORT_OP, true, "ssh port, used with --cluster option");
    options.addOption(null, ADVANCED_OP, false, "start in an advanced mode");
    options.addOption(null, ONE_HOST_CLUSTER_OP, false, "allow one host cluster");
    final CommandLineParser parser = new PosixParser();
    String autoArgs = null;
    try {
        final CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption(OUT_OP)) {
            final String out = cmd.getOptionValue(OUT_OP);
            if (out != null) {
                try {
                    System.setOut(new PrintStream(new FileOutputStream(out)));
                } catch (final FileNotFoundException e) {
                    System.exit(2);
                }
            }
        }
        if (cmd.hasOption(DEBUG_OP)) {
            final String level = cmd.getOptionValue(DEBUG_OP);
            if (level != null && Tools.isNumber(level)) {
                Tools.setDebugLevel(Integer.parseInt(level));
            } else {
                throw new ParseException("cannot parse debug level: " + level);
            }
        }
        boolean tightvnc = cmd.hasOption(TIGHTVNC_OP);
        boolean ultravnc = cmd.hasOption(ULTRAVNC_OP);
        final boolean realvnc = cmd.hasOption(REALVNC_OP);
        if (!tightvnc && !ultravnc && !realvnc) {
            if (Tools.isLinux()) {
                tightvnc = true;
            } else if (Tools.isWindows()) {
                ultravnc = true;
            } else {
                tightvnc = true;
                ultravnc = true;
            }
        }
        boolean advanced = cmd.hasOption(ADVANCED_OP);
        Tools.getConfigData().setAdvancedMode(advanced);
        Tools.getConfigData().setTightvnc(tightvnc);
        Tools.getConfigData().setUltravnc(ultravnc);
        Tools.getConfigData().setRealvnc(realvnc);

        Tools.getConfigData().setUpgradeCheckEnabled(!cmd.hasOption(NO_UPGRADE_CHECK_OP));
        Tools.getConfigData().setBigDRBDConf(cmd.hasOption(BIGDRBDCONF_OP));
        Tools.getConfigData().setStagingDrbd(cmd.hasOption(STAGING_DRBD_OP));
        Tools.getConfigData().setStagingPacemaker(cmd.hasOption(STAGING_PACEMAKER_OP));
        Tools.getConfigData().setNoLRM(cmd.hasOption(NOLRM_OP));
        Tools.getConfigData().setKeepHelper(cmd.hasOption(KEEP_HELPER_OP));
        Tools.getConfigData().setOneHostCluster(cmd.hasOption(ONE_HOST_CLUSTER_OP));
        final String pwd = System.getProperty("user.home");
        final String scaleOp = cmd.getOptionValue(SCALE_OP, "100");
        try {
            final int scale = Integer.parseInt(scaleOp);
            Tools.getConfigData().setScale(scale);
            Tools.resizeFonts(scale);
        } catch (java.lang.NumberFormatException e) {
            Tools.appWarning("cannot parse scale: " + scaleOp);
        }

        final String idDsaPath = cmd.getOptionValue(ID_DSA_OP, pwd + "/.ssh/id_dsa");
        final String idRsaPath = cmd.getOptionValue(ID_RSA_OP, pwd + "/.ssh/id_rsa");
        final String knownHostsPath = cmd.getOptionValue(KNOWN_HOSTS_OP, pwd + "/.ssh/known_hosts");
        Tools.getConfigData().setIdDSAPath(idDsaPath);
        Tools.getConfigData().setIdRSAPath(idRsaPath);
        Tools.getConfigData().setKnownHostPath(knownHostsPath);

        final String opMode = cmd.getOptionValue(OP_MODE_OP);
        autoArgs = cmd.getOptionValue(AUTO_OP);
        if (cmd.hasOption(HELP_OP)) {
            final HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("java -jar LCMC.jar [OPTIONS]", options);
            System.exit(0);
        }
        if (cmd.hasOption(VERSION_OP)) {
            System.out.println("LINUX CLUSTER MANAGEMENT CONSOLE " + Tools.getRelease() + " by Rasto Levrinc");
            System.exit(0);
        }
        if (cmd.hasOption("ro") || "ro".equals(opMode)) {
            Tools.getConfigData().setAccessType(ConfigData.AccessType.RO);
            Tools.getConfigData().setMaxAccessType(ConfigData.AccessType.RO);
        } else if (cmd.hasOption("op") || "op".equals(opMode)) {
            Tools.getConfigData().setAccessType(ConfigData.AccessType.OP);
            Tools.getConfigData().setMaxAccessType(ConfigData.AccessType.OP);
        } else if (cmd.hasOption("admin") || "admin".equals(opMode)) {
            Tools.getConfigData().setAccessType(ConfigData.AccessType.ADMIN);
            Tools.getConfigData().setMaxAccessType(ConfigData.AccessType.ADMIN);
        } else if (opMode != null) {
            Tools.appWarning("unknown operating mode: " + opMode);
        }
        if (cmd.hasOption(SLOW_OP)) {
            fps = fps / 2;
        }
        if (cmd.hasOption(RESTORE_MOUSE_OP)) {
            /* restore mouse if it is stuck in pressed state, during
             * robot tests. */
            RoboTest.restoreMouse();
        }
        final String vncPortOffsetString = cmd.getOptionValue(VNC_PORT_OFFSET_OP);
        if (vncPortOffsetString != null && Tools.isNumber(vncPortOffsetString)) {
            Tools.getConfigData().setVncPortOffset(Integer.parseInt(vncPortOffsetString));
        }
        Tools.getConfigData().setAnimFPS(fps);
        if (cmd.hasOption(CLUSTER_OP) || cmd.hasOption(HOST_OP)) {
            parseClusterOptions(cmd);
        }
    } catch (ParseException exp) {
        System.out.println("ERROR: " + exp.getMessage());
        System.exit(1);
    }
    Tools.debug(null, "max mem: " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + "m", 1);
    return autoArgs;
}

From source file:de.nmichael.efa.Daten.java

public static void iniGUI() {
    if (Logger.isTraceOn(Logger.TT_CORE, 9) || Logger.isDebugLoggingActivatedByCommandLine()) {
        Logger.log(Logger.DEBUG, Logger.MSG_CORE_STARTUPINITIALIZATION, "iniGUI()");
    }/*  w  w  w  .j  a v a2 s  .  co m*/
    if (!isGuiAppl()) {
        return;
    }
    iniScreenSize();

    // Look&Feel
    if (Daten.efaConfig != null) { // is null for applDRV
        try {
            if (Daten.efaConfig.getValueLookAndFeel().length() == 0) {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } else {
                UIManager.setLookAndFeel(Daten.efaConfig.getValueLookAndFeel());
            }
        } catch (Exception e) {
            Logger.log(Logger.WARNING, Logger.MSG_WARN_CANTSETLOOKANDFEEL,
                    International.getString("Konnte Look&Feel nicht setzen") + ": " + e.toString());
        }
    }

    // Look&Feel specific Work-Arounds
    try {
        lookAndFeel = UIManager.getLookAndFeel().getClass().toString();
        if (!lookAndFeel.endsWith("MetalLookAndFeel")) {
            // to make PopupMenu's work properly and not swallow the next MousePressed Event, see:
            // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6753637
            Dialog.getUiDefaults().put("PopupMenu.consumeEventOnClose", false);
        }
        Color buttonFocusColor = (Daten.efaConfig != null ? Daten.efaConfig.getLafButtonFocusColor() : null);
        if (buttonFocusColor != null) {
            // colored square around text of selected button
            Dialog.getUiDefaults().put("Button.focus", new ColorUIResource(buttonFocusColor));
        }
        // allow users to press buttons by hitting ENTER (and not just SPACE)
        Dialog.getUiDefaults().put("Button.focusInputMap",
                new javax.swing.UIDefaults.LazyInputMap(new Object[] { "ENTER", "pressed", "released ENTER",
                        "released", "SPACE", "pressed", "released SPACE", "released" }));
    } catch (Exception e) {
        Logger.log(Logger.WARNING, Logger.MSG_WARN_CANTSETLOOKANDFEEL,
                "Failed to apply LookAndFeel Workarounds: " + e.toString());
    }

    // Font Size
    if (applID == APPL_EFABH) {
        try {
            Dialog.setGlobalFontSize(Daten.efaConfig.getValueEfaDirekt_fontSize(),
                    Daten.efaConfig.getValueEfaDirekt_fontStyle());
        } catch (Exception e) {
            Logger.log(Logger.WARNING, Logger.MSG_WARN_CANTSETFONTSIZE,
                    International.getString("Schriftgre konnte nicht gendert werden") + ": "
                            + e.toString());
        }
    }
}

From source file:org.jets3t.gui.skins.html.SkinnedLookAndFeel.java

public SkinnedLookAndFeel(Properties skinProperties, String itemName) {
    super();/*w w w  .  ja  v a  2  s .com*/

    // Determine system defaults.
    JLabel defaultLabel = new JLabel();
    Color backgroundColor = defaultLabel.getBackground();
    Color textColor = defaultLabel.getForeground();
    Font font = defaultLabel.getFont();

    // Find skinning configurations.
    String backgroundColorValue = skinProperties.getProperty("backgroundColor", null);
    String textColorValue = skinProperties.getProperty("textColor", null);
    String fontValue = skinProperties.getProperty("font", null);

    // Apply skinning configurations.
    if (backgroundColorValue != null) {
        Color color = Color.decode(backgroundColorValue);
        if (color == null) {
            log.error("Unable to set background color with value: " + backgroundColorValue);
        } else {
            backgroundColor = color;
        }
    }
    if (textColorValue != null) {
        Color color = Color.decode(textColorValue);
        if (color == null) {
            log.error("Unable to set text color with value: " + textColorValue);
        } else {
            textColor = color;
        }
    }
    if (fontValue != null) {
        Font myFont = Font.decode(fontValue);
        if (myFont == null) {
            log.error("Unable to set font with value: " + fontValue);
        } else {
            font = myFont;
        }
    }

    // Update metal theme with configured display properties.
    SkinnedMetalTheme skinnedTheme = new SkinnedMetalTheme(new ColorUIResource(backgroundColor),
            new ColorUIResource(textColor), new FontUIResource(font));
    MetalLookAndFeel.setCurrentTheme(skinnedTheme);
}

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

/**
 * Sets the look and feel./*from   w  ww . j  av  a 2 s  .  c om*/
 * 
 * @param theme
 *            the new look and feel
 */
public void setLookAndFeel(String theme) {
    try {
        log.info("Updating skin '" + theme + "'");
        if (skins.containsKey(theme)) {
            UIManager.setLookAndFeel(skins.get(theme));
        } else {
            log.error("Not found skin '" + theme + "'");
            return;
        }

        /** fix font bug start */
        if (SwingUtilities.isEventDispatchThread()) {
            fixFontBug();
        } else {
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    fixFontBug();
                }
            });
        }
    } catch (Exception e) {
        log.error(e.toString(), e);
    }

    /**
     * ??????
     * tiptool
     */
    if (!isDefaultLookAndFeel(theme)) {
        // Get border color
        try {
            Color c = SubstanceLookAndFeel.getCurrentSkin().getMainActiveColorScheme().getMidColor();
            UIManager.put("ToolTip.border", BorderFactory.createLineBorder(c));
            UIManager.put("ToolTip.background", new ColorUIResource(Color.WHITE));
            UIManager.put("ToolTip.foreground", new ColorUIResource(Color.BLACK));

            SubstanceSkin skin = SubstanceLookAndFeel.getCurrentSkin();
            SubstanceColorScheme scheme = skin.getMainActiveColorScheme();

            GuiUtils.putLookAndFeelColor("borderColor", scheme.getMidColor());
            GuiUtils.putLookAndFeelColor("lightColor", scheme.getLightColor());
            GuiUtils.putLookAndFeelColor("lightBackgroundFillColor", scheme.getLightBackgroundFillColor());
            GuiUtils.putLookAndFeelColor("darkColor", scheme.getDarkColor());
            GuiUtils.putLookAndFeelColor("backgroundFillColor", scheme.getBackgroundFillColor());
            GuiUtils.putLookAndFeelColor("lineColor", scheme.getLineColor());
            GuiUtils.putLookAndFeelColor("selectionForegroundColor", scheme.getSelectionForegroundColor());
            GuiUtils.putLookAndFeelColor("selectionBackgroundColor", scheme.getSelectionBackgroundColor());
            GuiUtils.putLookAndFeelColor("foregroundColor", scheme.getForegroundColor());
            GuiUtils.putLookAndFeelColor("focusRingColor", scheme.getFocusRingColor());

        } catch (Exception e) {
            log.info("This is not a SubstanceLookAndFeel skin.");
        }

        UIManager.put(LafWidget.ANIMATION_KIND, LafConstants.AnimationKind.NONE);
        UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
                SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL);

        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
    }
}