Java Code Examples for javax.swing.UIManager#getColor()

The following examples show how to use javax.swing.UIManager#getColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateChooserPanel.java    From ccu-historian with GNU General Public License v3.0 8 votes vote down vote up
/**
 * Constructs a new date chooser panel.
 *
 * @param calendar     the calendar controlling the date.
 * @param controlPanel a flag that indicates whether or not the 'today' 
 *                     button should appear on the panel.
 */
public DateChooserPanel(final Calendar calendar, 
                        final boolean controlPanel) {

    super(new BorderLayout());

    this.chosenDateButtonColor = UIManager.getColor("textHighlight");
    this.chosenMonthButtonColor = UIManager.getColor("control");
    this.chosenOtherButtonColor = UIManager.getColor("controlShadow");

    // the default date is today...
    this.chosenDate = calendar;
    this.firstDayOfWeek = calendar.getFirstDayOfWeek();
    this.WEEK_DAYS = new int[7];
    for (int i = 0; i < 7; i++) {
        this.WEEK_DAYS[i] = ((this.firstDayOfWeek + i - 1) % 7) + 1;
    }

    add(constructSelectionPanel(), BorderLayout.NORTH);
    add(getCalendarPanel(), BorderLayout.CENTER);
    if (controlPanel) {
        add(constructControlPanel(), BorderLayout.SOUTH);
    }
    setDate(calendar.getTime());
}
 
Example 2
Source File: OQLEditorComponent.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void setEditable(boolean b) {
    if (queryEditor.isEditable() == b) return;
    
    queryEditor.setEditable(b);

    if (b) {
        if (lastBgColor != null) queryEditor.setBackground(lastBgColor);
        if (lastCaret != null) queryEditor.setCaret(lastCaret);
    } else {
        lastBgColor = queryEditor.getBackground();
        lastCaret = queryEditor.getCaret();
        
        Color disabledBackground = UIUtils.isGTKLookAndFeel() ?
              UIManager.getLookAndFeel().getDefaults().getColor("desktop") : // NOI18N
              UIManager.getColor("TextField.disabledBackground"); // NOI18N
        queryEditor.setBackground(disabledBackground);
        queryEditor.setCaret(new NoCaret());
    }
}
 
Example 3
Source File: CSSStylesSelectionPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Builds the layout of the rendered component.
 */
private void buildLayout() {
    GroupLayout layout = new GroupLayout(renderer);
    GroupLayout.Group hGroup = layout.createSequentialGroup()
            .addComponent(selectorLabel, 1, 1, Short.MAX_VALUE)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup()
                .addComponent(matchedNodeLabel, 1, 1, Short.MAX_VALUE)
                .addComponent(ruleLocationPanel, 1, 1, Short.MAX_VALUE)
            );
    GroupLayout.Group vGroup = layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addComponent(selectorLabel)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(matchedNodeLabel)
                    .addComponent(ruleLocationPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                ))
            .addGap(0, 0, Short.MAX_VALUE);
    hGroup = layout.createParallelGroup()
            .addComponent(mediaLabel, 1, 1, Short.MAX_VALUE)
            .addGroup(hGroup);
    vGroup = layout.createSequentialGroup()
            .addComponent(mediaLabel)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(vGroup);
    layout.setHorizontalGroup(hGroup);
    layout.setVerticalGroup(vGroup);
    renderer.setLayout(layout);
    Color borderColor = UIManager.getColor("Label.background"); // NOI18N
    renderer.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createMatteBorder(0, 0, 1, 0, borderColor),
        BorderFactory.createEmptyBorder(2, 2, 2, 2)));
}
 
Example 4
Source File: WindowsInternalFrameTitlePane.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void installDefaults() {
    super.installDefaults();

    titlePaneHeight = UIManager.getInt("InternalFrame.titlePaneHeight");
    buttonWidth     = UIManager.getInt("InternalFrame.titleButtonWidth")  - 4;
    buttonHeight    = UIManager.getInt("InternalFrame.titleButtonHeight") - 4;

    Object obj      = UIManager.get("InternalFrame.titleButtonToolTipsOn");
    hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;


    if (XPStyle.getXP() != null) {
        // Fix for XP bug where sometimes these sizes aren't updated properly
        // Assume for now that height is correct and derive width using the
        // ratio from the uxtheme part
        buttonWidth = buttonHeight;
        Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
        if (d != null && d.width != 0 && d.height != 0) {
            buttonWidth = (int) ((float) buttonWidth * d.width / d.height);
        }
    } else {
        buttonWidth += 2;
        Color activeBorderColor =
                UIManager.getColor("InternalFrame.activeBorderColor");
        setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
    }
    // JDK-8039383: initialize these colors because getXP() may return null when theme is changed
    selectedTitleGradientColor =
            UIManager.getColor("InternalFrame.activeTitleGradient");
    notSelectedTitleGradientColor =
            UIManager.getColor("InternalFrame.inactiveTitleGradient");
}
 
Example 5
Source File: MotifSplitPaneDivider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 6
Source File: WindowsLFCustoms.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Object[] createKeysAndValues() {
    return new Object[] {
    //Property sheet settings as defined by HIE
    PROPSHEET_SELECTION_BACKGROUND, new Color(10,36,106),
    PROPSHEET_SELECTION_FOREGROUND, Color.WHITE,
    PROPSHEET_SET_BACKGROUND, new Color(237,233,225),
    PROPSHEET_SET_FOREGROUND, Color.BLACK,
    PROPSHEET_SELECTED_SET_BACKGROUND, new Color(10,36,106),
    PROPSHEET_SELECTED_SET_FOREGROUND, Color.WHITE,
    PROPSHEET_DISABLED_FOREGROUND, new Color(128,128,128),
    PROPSHEET_BUTTON_COLOR, UIManager.getColor("control"),
    };
}
 
Example 7
Source File: SwitcherTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Color getForeground() {
    if (foreground == null) {
        foreground = UIManager.getColor( "nb.popupswitcher.foreground" ); //NOI18N
        if (foreground == null)
            foreground = UIManager.getColor("ComboBox.foreground"); //NOI18N
    }
    return foreground != null ? foreground : super.getForeground();
}
 
Example 8
Source File: DerivedColor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a string representation of this <code>Color</code>. This method
 * is intended to be used only for debugging purposes. The content and
 * format of the returned string might vary between implementations. The
 * returned string might be empty but cannot be <code>null</code>.
 *
 * @return a String representation of this <code>Color</code>.
 */
@Override
public String toString() {
    Color src = UIManager.getColor(uiDefaultParentName);
    String s = "DerivedColor(color=" + getRed() + "," + getGreen() + "," + getBlue() +
            " parent=" + uiDefaultParentName +
            " offsets=" + getHueOffset() + "," + getSaturationOffset() + ","
            + getBrightnessOffset() + "," + getAlphaOffset();
    return src == null ? s : s + " pColor=" + src.getRed() + "," + src.getGreen() + "," + src.getBlue();
}
 
Example 9
Source File: NewPluginPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Border getNbScrollPaneBorder () {
    Border b = UIManager.getBorder("Nb.ScrollPane.border");
    if (b == null) {
        Color c = UIManager.getColor("controlShadow");
        b = new LineBorder(c != null ? c : Color.GRAY);
    }
    return b;
}
 
Example 10
Source File: UIUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Color getLinkColor() {
    Color res = UIManager.getColor( "nb.html.link.foreground" );//NOI18N
    if( null == res ) {
        res = Color.blue;
    }
    return res;
}
 
Example 11
Source File: DerivedColor.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a string representation of this <code>Color</code>. This method
 * is intended to be used only for debugging purposes. The content and
 * format of the returned string might vary between implementations. The
 * returned string might be empty but cannot be <code>null</code>.
 *
 * @return a String representation of this <code>Color</code>.
 */
@Override
public String toString() {
    Color src = UIManager.getColor(uiDefaultParentName);
    String s = "DerivedColor(color=" + getRed() + "," + getGreen() + "," + getBlue() +
            " parent=" + uiDefaultParentName +
            " offsets=" + getHueOffset() + "," + getSaturationOffset() + ","
            + getBrightnessOffset() + "," + getAlphaOffset();
    return src == null ? s : s + " pColor=" + src.getRed() + "," + src.getGreen() + "," + src.getBlue();
}
 
Example 12
Source File: MotifSplitPaneDivider.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Creates a new Motif SplitPaneDivider
 */
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
    super(ui);
    highlightColor = UIManager.getColor("SplitPane.highlight");
    shadowColor = UIManager.getColor("SplitPane.shadow");
    focusedColor = UIManager.getColor("SplitPane.activeThumb");
    setDividerSize(hThumbWidth + pad);
}
 
Example 13
Source File: LookAndFeel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isCurrentLookAndFeelDark() {
  final Color background = UIManager.getColor("Panel.background");
  return background != null && isColorDark(background);
}
 
Example 14
Source File: AquaTabbedPaneContrastUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected static Color getSelectedTabTitleShadowColor(boolean enabled) {
    return enabled ? UIManager.getColor("TabbedPane.selectedTabTitleShadowNormalColor") : UIManager.getColor("TabbedPane.selectedTabTitleShadowDisabledColor");
}
 
Example 15
Source File: StyleSheet.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Paints the CSS list decoration according to the
 * attributes given.
 *
 * @param g the rendering surface.
 * @param x the x coordinate of the list item allocation
 * @param y the y coordinate of the list item allocation
 * @param w the width of the list item allocation
 * @param h the height of the list item allocation
 * @param v the allocated area to paint into.
 * @param item which list item is being painted.  This
 *  is a number greater than or equal to 0.
 */
public void paint(Graphics g, float x, float y, float w, float h, View v, int item) {
    View cv = v.getView(item);
    Container host = v.getContainer();
    Object name = cv.getElement().getAttributes().getAttribute
                 (StyleConstants.NameAttribute);
    // Only draw something if the View is a list item. This won't
    // be the case for comments.
    if (!(name instanceof HTML.Tag) ||
        name != HTML.Tag.LI) {
        return;
    }
    // deside on what side draw bullets, etc.
    isLeftToRight =
        host.getComponentOrientation().isLeftToRight();

    // How the list indicator is aligned is not specified, it is
    // left up to the UA. IE and NS differ on this behavior.
    // This is closer to NS where we align to the first line of text.
    // If the child is not text we draw the indicator at the
    // origin (0).
    float align = 0;
    if (cv.getViewCount() > 0) {
        View pView = cv.getView(0);
        Object cName = pView.getElement().getAttributes().
                       getAttribute(StyleConstants.NameAttribute);
        if ((cName == HTML.Tag.P || cName == HTML.Tag.IMPLIED) &&
                      pView.getViewCount() > 0) {
            paintRect.setBounds((int)x, (int)y, (int)w, (int)h);
            Shape shape = cv.getChildAllocation(0, paintRect);
            if (shape != null && (shape = pView.getView(0).
                         getChildAllocation(0, shape)) != null) {
                Rectangle rect = (shape instanceof Rectangle) ?
                                 (Rectangle)shape : shape.getBounds();

                align = pView.getView(0).getAlignment(View.Y_AXIS);
                y = rect.y;
                h = rect.height;
            }
        }
    }

    // set the color of a decoration
    Color c = (host.isEnabled()
        ? (ss != null
            ? ss.getForeground(cv.getAttributes())
            : host.getForeground())
        : UIManager.getColor("textInactiveText"));
    g.setColor(c);

    if (img != null) {
        drawIcon(g, (int) x, (int) y, (int) w, (int) h, align, host);
        return;
    }
    CSS.Value childtype = getChildType(cv);
    Font font = ((StyledDocument)cv.getDocument()).
                                 getFont(cv.getAttributes());
    if (font != null) {
        g.setFont(font);
    }
    if (childtype == CSS.Value.SQUARE || childtype == CSS.Value.CIRCLE
        || childtype == CSS.Value.DISC) {
        drawShape(g, childtype, (int) x, (int) y,
                  (int) w, (int) h, align);
    } else if (childtype == CSS.Value.DECIMAL) {
        drawLetter(g, '1', (int) x, (int) y, (int) w, (int) h, align,
                   getRenderIndex(v, item));
    } else if (childtype == CSS.Value.LOWER_ALPHA) {
        drawLetter(g, 'a', (int) x, (int) y, (int) w, (int) h, align,
                   getRenderIndex(v, item));
    } else if (childtype == CSS.Value.UPPER_ALPHA) {
        drawLetter(g, 'A', (int) x, (int) y, (int) w, (int) h, align,
                   getRenderIndex(v, item));
    } else if (childtype == CSS.Value.LOWER_ROMAN) {
        drawLetter(g, 'i', (int) x, (int) y, (int) w, (int) h, align,
                   getRenderIndex(v, item));
    } else if (childtype == CSS.Value.UPPER_ROMAN) {
        drawLetter(g, 'I', (int) x, (int) y, (int) w, (int) h, align,
                   getRenderIndex(v, item));
    }
}
 
Example 16
Source File: sun_swing_PrintColorUIResource.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected Color getObject() {
    return UIManager.getColor("TitledBorder.titleColor");
}
 
Example 17
Source File: ScrollBarUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void configureScrollBarColors() {
	super.configureScrollBarColors();
	this.thumbColor = UIManager.getColor("ScrollBar.thumb");
	this.thumbHighlightColor = UIManager.getColor("ScrollBar.thumbHighlight");
}
 
Example 18
Source File: WinUtils.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
	 * Paint classic text.
	 *
	 * @param b the b
	 * @param g the g
	 * @param x the x
	 * @param y the y
	 * @param text the text
	 * @param mnemIndex the mnem index
	 */
	static void paintClassicText(AbstractButton b, Graphics g, int x, int y,
			String text, int mnemIndex) {
		ButtonModel model = b.getModel();

		/* Draw the Text */
		Color color = b.getForeground();
		if(model.isEnabled()) {
			/*** paint the text normally */
			if(!(b instanceof JMenuItem && model.isArmed()) 
					&& !(b instanceof JMenu && (model.isSelected() || model.isRollover()))) {
				/* We shall not set foreground color for selected menu or
				 * armed menuitem. Foreground must be set in appropriate
				 * Windows* class because these colors passes from
				 * BasicMenuItemUI as protected fields and we can't
				 * reach them from this class */
				g.setColor(b.getForeground());
			}
//			SwingUtilities2.drawStringUnderlineCharAt(b, g,text, mnemIndex, x, y);
			MySwingUtilities2.drawStringUnderlineCharAt(b
					, g,text, mnemIndex, x, y);//* modified by Jack Jiang 为了非公开api的兼容性
		} else {	/*** paint the text disabled ***/
			color        = UIManager.getColor("Button.shadow");
			Color shadow = UIManager.getColor("Button.disabledShadow");
			if(model.isArmed()) {
				color = UIManager.getColor("Button.disabledForeground");
			} else {
				if (shadow == null) {
					shadow = b.getBackground().darker();
				}
				g.setColor(shadow);
//				SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
//						x + 1, y + 1);
				MySwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
						x + 1, y + 1);//* modified by Jack Jiang 为了非公开api的兼容性
			}
			if (color == null) {
				color = b.getBackground().brighter();
			}
			g.setColor(color);
//			SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
			MySwingUtilities2.drawStringUnderlineCharAt(
					b, g, text, mnemIndex, x, y);//* modified by Jack Jiang 为了非公开api的兼容性
			
		}
	}
 
Example 19
Source File: FlatCapsLockIcon.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
public FlatCapsLockIcon() {
	super( 16, 16, UIManager.getColor( "PasswordField.capsLockIconColor" ) );
}
 
Example 20
Source File: AquaTabbedPaneContrastUI.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected static Color getNonSelectedTabTitleColor() {
    return UIManager.getColor("TabbedPane.nonSelectedTabTitleNormalColor");
}