java.awt.SystemColor Java Examples

The following examples show how to use java.awt.SystemColor. 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: ColorComboBoxRenderer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent (
    JList<? extends ColorValue>
                list,
    ColorValue  value,
    int         index,
    boolean     isSelected,
    boolean     cellHasFocus
) {
    this.value = value;
    setEnabled (list.isEnabled ());
    setBackground (isSelected ? 
        SystemColor.textHighlight : SystemColor.text
        //Color.RED
    );
    setForeground (isSelected ? 
        SystemColor.textHighlightText : SystemColor.textText
    );
    return this;
}
 
Example #2
Source File: ColoredProgressBar.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
public ColoredProgressBar(int start, int end) {
    setMinimum(start);
    setMaximum(end);
    setForeground(SystemColor.window);
    setBackground(SystemColor.window);
    setBorder(new EmptyBorder(3, 5, 3, 5));
    Dimension size = new Dimension(300, 20);
    setPreferredSize(size);
    setMaximumSize(size);
    setMinimumSize(size);
    BasicProgressBarUI ui = new BasicProgressBarUI() {

        @Override
        protected Color getSelectionForeground() {
            return Color.BLACK;
        }

        @Override
        protected Color getSelectionBackground() {
            return Color.BLACK;
        }
    };
    setUI(ui);
}
 
Example #3
Source File: BrowserConsoleLogger.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void setIOColors() {
    if (IOColors.isSupported(io) && IOColorPrint.isSupported(io)) {
        Color colorStd = IOColors.getColor(io, IOColors.OutputType.OUTPUT);
        //Color colorErr = IOColors.getColor(io, IOColors.OutputType.ERROR);
        Color background = UIManager.getDefaults().getColor("nb.output.background");    // NOI18N
        if (background == null) {
            background = SystemColor.window;
        }
        colorStdBrighter = shiftTowards(colorStd, background);
        //colorErrBrighter = shiftTowards(colorErr, background);
        Color foreground = UIManager.getDefaults().getColor("nb.output.foreground");    // NOI18N
        if (foreground == null) {
            foreground = SystemColor.textText;
        }
        IOColors.setColor(io, IOColors.OutputType.INPUT, shiftTowards(foreground, Color.GREEN));
    }
}
 
Example #4
Source File: Editor.java    From jclic with GNU General Public License v2.0 6 votes vote down vote up
public JTree createJTree() {
  setCurrentTree(new JTree(getTreeModel()));
  currentTree.setCellRenderer(new DefaultTreeCellRenderer() {
    @Override
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {
      super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
      if (value instanceof Editor) {
        Icon icon = ((Editor) value).getIcon(leaf, expanded);
        if (icon != null)
          setIcon(icon);
        if (clip == value && clipCutted) {
          setForeground(SystemColor.textInactiveText);
        }
      }
      return this;
    }
  });
  return currentTree;
}
 
Example #5
Source File: AquaAudioListUI.java    From pumpernickel with MIT License 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list,
		Object soundObject, int row, boolean isSelected,
		boolean hasFocus) {
	label.setText(getSoundName(soundObject));

	if (isSelected) {
		label.setOpaque(true);
		label.setBackground(SystemColor.textHighlight);
		label.setForeground(SystemColor.textHighlightText);
	} else {
		label.setOpaque(list.isOpaque());
		label.setBackground(SystemColor.text);
		label.setForeground(SystemColor.textText);
	}
	return label;
}
 
Example #6
Source File: SystemColorSupport.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the Value corresponding to the given system color.
 */
public static CSSValue getSystemColor(String ident) {
    ident = ident.toLowerCase();
    SystemColor sc = (SystemColor)factories.get(ident);
    return new RGBColorValue
        (new FloatValue(CSSPrimitiveValue.CSS_NUMBER, sc.getRed()),
         new FloatValue(CSSPrimitiveValue.CSS_NUMBER, sc.getGreen()),
         new FloatValue(CSSPrimitiveValue.CSS_NUMBER, sc.getBlue()));
}
 
Example #7
Source File: WallpaperGUI.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public void selected(boolean s) {
	selected = s;
	if (selected)
		setBackground(SystemColor.inactiveCaption);
	else
		setBackground(c);
}
 
Example #8
Source File: BackgroundComboBox.java    From energy2d with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void paintIcon(Component c, Graphics g, int x, int y) {
	int w = getIconWidth();
	int h = getIconHeight();
	Polygon triangle = new Polygon();
	triangle.addPoint(x, y);
	triangle.addPoint(x + w, y);
	triangle.addPoint(x + w / 2, y + h);
	g.setColor(popButton.isEnabled() ? SystemColor.textText : SystemColor.textInactiveText);
	g.fillPolygon(triangle);
}
 
Example #9
Source File: SwingUtil.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void setEnabledWithBackground(Component comp, boolean isEnabled)
{
  comp.setEnabled(isEnabled);
  if (isEnabled)
    comp.setBackground(SystemColor.text);
  else
    comp.setBackground(SystemColor.control);
}
 
Example #10
Source File: LayerListPanel.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void uiInit() throws Exception {
    setSize(200, 250);
    setLayout(borderLayout2);
    list.setBackground(SystemColor.control);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectionBackground(Color.GRAY);
    add(jScrollPane1, BorderLayout.CENTER);
    jScrollPane1.getViewport().add(list, null);
}
 
Example #11
Source File: XComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an array of Colors similar to getGUIcolors(), but using the
 * System colors.  This is useful if pieces of a Component (such as
 * the integrated scrollbars of a List) should retain the System color
 * instead of the background color set by Component.setBackground().
 */
static Color[] getSystemColors() {
    if (systemColors == null) {
        systemColors = new Color[4];
        systemColors[BACKGROUND_COLOR] = SystemColor.window;
        systemColors[HIGHLIGHT_COLOR] = SystemColor.controlLtHighlight;
        systemColors[SHADOW_COLOR] = SystemColor.controlShadow;
        systemColors[FOREGROUND_COLOR] = SystemColor.windowText;
    }
    return systemColors;
}
 
Example #12
Source File: TimelinePanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public static Color getBackgroundColor() {
    if (Configuration.useRibbonInterface.get()) {
        return SubstanceLookAndFeel.getCurrentSkin().getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getBackgroundFillColor();
    } else {
        return SystemColor.control;
    }
}
 
Example #13
Source File: TimelineBodyPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
private static Color getControlColor() {
    if (Configuration.useRibbonInterface.get()) {
        return SubstanceLookAndFeel.getCurrentSkin().getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getBackgroundFillColor();
    } else {
        return SystemColor.control;
    }
}
 
Example #14
Source File: TimelineBodyPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public static Color getSelectedColor() {
    if (Configuration.useRibbonInterface.get()) {
        return SubstanceLookAndFeel.getCurrentSkin().getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ROLLOVER_SELECTED).getBackgroundFillColor();
    } else {
        return SystemColor.textHighlight;
    }
}
 
Example #15
Source File: ComboBoxRenderer.java    From energy2d with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
	setBackground(isSelected ? SystemColor.textHighlight : Color.white);
	setForeground(isSelected ? SystemColor.textHighlightText : Color.black);
	setHorizontalAlignment(CENTER);
	if (value instanceof Icon) {
		setIcon((Icon) value);
		if (value instanceof ImageIcon) {
			setToolTipText(((ImageIcon) value).getDescription());
		}
	} else {
		setText(value == null ? "Unknown" : value.toString());
	}
	return this;
}
 
Example #16
Source File: LWTextComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
LWTextComponentPeer(final T target,
                    final PlatformComponent platformComponent) {
    super(target, platformComponent);
    if (!getTarget().isBackgroundSet()) {
        getTarget().setBackground(SystemColor.text);
    }
}
 
Example #17
Source File: XComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an array of Colors similar to getGUIcolors(), but using the
 * System colors.  This is useful if pieces of a Component (such as
 * the integrated scrollbars of a List) should retain the System color
 * instead of the background color set by Component.setBackground().
 */
static Color[] getSystemColors() {
    if (systemColors == null) {
        systemColors = new Color[4];
        systemColors[BACKGROUND_COLOR] = SystemColor.window;
        systemColors[HIGHLIGHT_COLOR] = SystemColor.controlLtHighlight;
        systemColors[SHADOW_COLOR] = SystemColor.controlShadow;
        systemColors[FOREGROUND_COLOR] = SystemColor.windowText;
    }
    return systemColors;
}
 
Example #18
Source File: LWTextComponentPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
LWTextComponentPeer(final T target,
                    final PlatformComponent platformComponent) {
    super(target, platformComponent);
    if (!getTarget().isBackgroundSet()) {
        getTarget().setBackground(SystemColor.text);
    }
}
 
Example #19
Source File: GedEntryComponent.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public void setCallable(Callable<Void> callable)
{
	addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent me) {
			
			if(me.getClickCount()==2)
			{
				try {
					callable.call();
				} catch (Exception e) {
					logger.error(e);
				}
				
			}
			else
			{
				selected=!selected;

				if(selected)
					setBackground(SystemColor.activeCaption);
				else
					setBackground(defaultColor);
			}
			
			
			
			
			
		}
	});
}
 
Example #20
Source File: LWTextComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
LWTextComponentPeer(final T target,
                    final PlatformComponent platformComponent) {
    super(target, platformComponent);
    if (!getTarget().isBackgroundSet()) {
        getTarget().setBackground(SystemColor.text);
    }
}
 
Example #21
Source File: AquaListLocationBrowserUI.java    From pumpernickel with MIT License 5 votes vote down vote up
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {
	String text = "";
	Icon icon = null;

	if (value instanceof IOLocation) {
		IOLocation l = (IOLocation) value;
		text = l.getName();
		icon = graphicCache.requestIcon(l);
		if (icon == null) {
			if (l.isDirectory()) {
				icon = IOLocation.FOLDER_ICON;
			} else {
				icon = IOLocation.FILE_ICON;
			}
		}
		icon = IconUtils.createPaddedIcon(icon, iconPadding);
	} else {
		text = value.toString();
	}

	label.setIcon(icon);
	label.setText(text);
	if (isSelected) {
		label.setForeground(SystemColor.controlLtHighlight);
		label.setBackground(SystemColor.controlHighlight);
	} else {
		label.setForeground(foreground);
		if (row % 2 == 0) {
			label.setBackground(background);
		} else {
			label.setBackground(altBackground);
		}
	}
	label.setOpaque(true);

	return label;
}
 
Example #22
Source File: MixedCheckBoxState.java    From pumpernickel with MIT License 5 votes vote down vote up
protected static void paintTick(Graphics g, int x, int y, int w, int h) {
	Graphics2D g2 = (Graphics2D) g.create();

	// on Macs we want the rich dark blue of controlHighlight,
	// but on Windows controlDkShadow is better. Let's check both
	// and pick one that has sufficient contrast

	g2.setColor(SystemColor.controlText);

	for (Color color : new Color[] { SystemColor.controlHighlight,
			SystemColor.controlDkShadow }) {
		float hsbDistance = getHSBDistance(SystemColor.window, color);
		if (hsbDistance > 1) {
			g2.setColor(color);
			break;
		}
	}
	g2.setStroke(new BasicStroke(2.1f));
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
			RenderingHints.VALUE_STROKE_PURE);
	int k = Math.min(w, h) / 5;
	int cx = x + w / 2;
	int cy = y + h / 2;
	if (JVM.isMac) {
		// this make the rendering symmetrical; I'm not sure why platforms
		// vary
		g2.draw(new Line2D.Float(cx - k, cy - k, cx + k, cy + k));
	} else {
		g2.draw(new Line2D.Float(cx - k, cy - k, cx + k + 1, cy + k + 1));
	}
	g2.dispose();
}
 
Example #23
Source File: NudgeSearchHighlight.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected void paintHighlightBackground(Graphics2D g, Rectangle textRect) {
	g.setPaint(SystemColor.textHighlight);
	g.fillRect(textRect.x - i.left, textRect.y - i.top, textRect.width
			+ i.left + i.right, textRect.height + i.top + i.bottom);
	g.setPaint(SystemColor.controlShadow);
	g.drawRect(textRect.x - i.left, textRect.y - i.top, textRect.width
			+ i.left + i.right - 1, textRect.height + i.top + i.bottom - 1);
}
 
Example #24
Source File: DecoratedDemo.java    From pumpernickel with MIT License 5 votes vote down vote up
public ListDemo() {
	setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;
	add(getDecoratedComponent(), c);

	getDecoratedComponent().putClientProperty(
			DecoratedListUI.KEY_DECORATIONS,
			new ListDecoration[] { progressDecoration, starDecoration1,
					starDecoration2, starDecoration3, starDecoration4,
					starDecoration5, closeDecoration,
					playPauseDecoration, warningDecoration,
					refreshDecoration });

	getDecoratedComponent().setUI(new DecoratedListUI());
	LabelCellRenderer<String> r = new LabelCellRenderer<String>() {

		@Override
		protected void formatLabelColors(JComponent jc,
				boolean isSelected, int rowNumber) {
			super.formatLabelColors(jc, isSelected, rowNumber);
			if (isSelected) {
				label.setBackground(SystemColor.textHighlight);
				label.setForeground(SystemColor.textHighlightText);
			}
		}
	};
	getDecoratedComponent().setCellRenderer(r);
	getDecoratedComponent().setFixedCellHeight(24);
	getDecoratedComponent().setPreferredSize(new Dimension(200, 150));
}
 
Example #25
Source File: TextBoxPaintable.java    From pumpernickel with MIT License 5 votes vote down vote up
public TextBoxPaintable(String string, Font font, float maxWidth,
		float insets, Paint paint) {
	if (paint == null)
		paint = SystemColor.textText;
	this.insets = insets;
	this.text = string;
	this.paint = paint;

	List<String> lines = new ArrayList<String>();
	Map<TextAttribute, Object> attributes = new HashMap<TextAttribute, Object>();
	attributes.put(TextAttribute.FONT, font);
	AttributedString attrString = new AttributedString(string, attributes);
	LineBreakMeasurer lbm = new LineBreakMeasurer(attrString.getIterator(),
			frc);
	TextLayout tl = lbm.nextLayout(maxWidth);
	float dy = 0;
	GeneralPath path = new GeneralPath();
	int startIndex = 0;
	while (tl != null) {
		path.append(
				tl.getOutline(AffineTransform.getTranslateInstance(0, dy)),
				false);
		dy += tl.getAscent() + tl.getDescent() + tl.getLeading();
		int charCount = tl.getCharacterCount();
		lines.add(text.substring(startIndex, startIndex + charCount));
		startIndex += charCount;
		tl = lbm.nextLayout(maxWidth);
	}
	this.lines = lines.toArray(new String[lines.size()]);
	untransformedShape = path;
	Rectangle2D b = ShapeBounds.getBounds(untransformedShape);
	b.setFrame(b.getX(), b.getY(), b.getWidth() + 2 * insets, b.getHeight()
			+ 2 * insets);
	untransformedBounds = b.getBounds();
}
 
Example #26
Source File: XComponentPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an array of Colors similar to getGUIcolors(), but using the
 * System colors.  This is useful if pieces of a Component (such as
 * the integrated scrollbars of a List) should retain the System color
 * instead of the background color set by Component.setBackground().
 */
static Color[] getSystemColors() {
    if (systemColors == null) {
        systemColors = new Color[4];
        systemColors[BACKGROUND_COLOR] = SystemColor.window;
        systemColors[HIGHLIGHT_COLOR] = SystemColor.controlLtHighlight;
        systemColors[SHADOW_COLOR] = SystemColor.controlShadow;
        systemColors[FOREGROUND_COLOR] = SystemColor.windowText;
    }
    return systemColors;
}
 
Example #27
Source File: StatusBar.java    From clipper-java with Boost Software License 1.0 5 votes vote down vote up
public StatusBar() {
    setLayout( new BorderLayout() );
    setPreferredSize( new Dimension( 10, 23 ) );

    final JPanel rightPanel = new JPanel( new BorderLayout() );
    rightPanel.add( new JLabel( new AngledLinesWindowsCornerIcon() ), BorderLayout.SOUTH );
    rightPanel.setOpaque( false );

    text = new JLabel();
    add( text, BorderLayout.WEST );
    add( rightPanel, BorderLayout.EAST );
    setBackground( SystemColor.control );
}
 
Example #28
Source File: XComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an array of Colors similar to getGUIcolors(), but using the
 * System colors.  This is useful if pieces of a Component (such as
 * the integrated scrollbars of a List) should retain the System color
 * instead of the background color set by Component.setBackground().
 */
static Color[] getSystemColors() {
    if (systemColors == null) {
        systemColors = new Color[4];
        systemColors[BACKGROUND_COLOR] = SystemColor.window;
        systemColors[HIGHLIGHT_COLOR] = SystemColor.controlLtHighlight;
        systemColors[SHADOW_COLOR] = SystemColor.controlShadow;
        systemColors[FOREGROUND_COLOR] = SystemColor.windowText;
    }
    return systemColors;
}
 
Example #29
Source File: LWTextComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
LWTextComponentPeer(final T target,
                    final PlatformComponent platformComponent) {
    super(target, platformComponent);
    if (!getTarget().isBackgroundSet()) {
        getTarget().setBackground(SystemColor.text);
    }
}
 
Example #30
Source File: XComponentPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an array of Colors similar to getGUIcolors(), but using the
 * System colors.  This is useful if pieces of a Component (such as
 * the integrated scrollbars of a List) should retain the System color
 * instead of the background color set by Component.setBackground().
 */
static Color[] getSystemColors() {
    if (systemColors == null) {
        systemColors = new Color[4];
        systemColors[BACKGROUND_COLOR] = SystemColor.window;
        systemColors[HIGHLIGHT_COLOR] = SystemColor.controlLtHighlight;
        systemColors[SHADOW_COLOR] = SystemColor.controlShadow;
        systemColors[FOREGROUND_COLOR] = SystemColor.windowText;
    }
    return systemColors;
}