Java Code Examples for java.awt.Component#getForeground()

The following examples show how to use java.awt.Component#getForeground() . 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: TriangleIcon.java    From pumpernickel with MIT License 6 votes vote down vote up
public void paintIcon(Component c, Graphics g, int x, int y) {
	Graphics2D g2 = (Graphics2D) g.create();
	g2.translate(x, y);
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	if (color == null) {
		if (c != null && c.getForeground() != null) {
			g2.setColor(c.getForeground());
		} else {
			g2.setColor(Color.darkGray);
		}
	} else {
		g2.setColor(color);
	}
	g2.fill(triangle);
}
 
Example 2
Source File: TimelineHeaderRenderer.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
private static void initStaticUI(Component c, JTableHeader header) {
    painter = new LabelRenderer(true);
    
    Color color = c.getForeground();
    if (color == null) color = header.getForeground();
    if (color == null) color = UIManager.getColor("TableHeader.foreground"); // NOI18N
    if (color != null) painter.setForeground(color);
    Font font = c.getFont();
    if (font == null) font = header.getFont();
    if (font == null) font = UIManager.getFont("TableHeader.font"); // NOI18N
    if (font != null) painter.setFont(font);
    
    if (UIUtils.isWindowsXPLookAndFeel()) Y_LAF_OFFSET = 1;
    else if (UIUtils.isNimbusLookAndFeel()) Y_LAF_OFFSET = -1;
    else Y_LAF_OFFSET = 0;
}
 
Example 3
Source File: TimelineHeaderRenderer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void initStaticUI(Component c, JTableHeader header) {
    painter = new LabelRenderer(true);
    
    Color color = c.getForeground();
    if (color == null) color = header.getForeground();
    if (color == null) color = UIManager.getColor("TableHeader.foreground"); // NOI18N
    if (color != null) painter.setForeground(color);
    Font font = c.getFont();
    if (font == null) font = header.getFont();
    if (font == null) font = UIManager.getFont("TableHeader.font"); // NOI18N
    if (font != null) painter.setFont(font);
    
    if (UIUtils.isWindowsXPLookAndFeel()) Y_LAF_OFFSET = 1;
    else if (UIUtils.isNimbusLookAndFeel()) Y_LAF_OFFSET = -1;
    else Y_LAF_OFFSET = 0;
}
 
Example 4
Source File: TitledBorder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 5
Source File: PaletteUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
	Component c = e.getComponent();
	JPalette palette;
	Point palettePoint = e.getPoint();
	if (c instanceof JToggleButton) {
		palette = (JPalette) c.getParent();
		palettePoint = SwingUtilities.convertPoint(c, palettePoint,
				palette);
	} else {
		palette = (JPalette) c;
	}

	if (!palette.isEnabled())
		return;

	if (palette.isRequestFocusEnabled())
		palette.requestFocus();

	Insets i = palette.getInsets();
	palettePoint.x = Math.max(i.left + 1, Math.min(palette.getWidth()
			- i.right - i.left - 1, palettePoint.x));
	palettePoint.y = Math.max(i.top + 1, Math.min(palette.getHeight()
			- i.top - i.bottom - 1, palettePoint.y));

	Component c2 = SwingUtilities.getDeepestComponentAt(palette,
			palettePoint.x, palettePoint.y);
	if (c2 != null && c2 instanceof JToggleButton) {
		Color f = c2.getForeground();
		palette.getColorSelectionModel().setSelectedColor(f);
	}
}
 
Example 6
Source File: TitledBorder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 7
Source File: TitledBorder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 8
Source File: TitledBorder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 9
Source File: TitledBorder.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 10
Source File: TitledBorder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 11
Source File: TitledBorder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 12
Source File: LootTrackerBox.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void applyDimmer(boolean brighten, JPanel panel)
{
	for (Component component : panel.getComponents())
	{
		Color color = component.getForeground();

		component.setForeground(brighten ? color.brighter() : color.darker());
	}
}
 
Example 13
Source File: TitledBorder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 14
Source File: TitledBorder.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 15
Source File: TitledBorder.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 16
Source File: LootTrackerBox.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void applyDimmer(boolean brighten, JPanel panel)
{
	for (Component component : panel.getComponents())
	{
		Color color = component.getForeground();

		component.setForeground(brighten ? color.brighter() : color.darker());
	}
}
 
Example 17
Source File: StyleEditor.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
Style(Component c) {
     if(c instanceof JLabel) {
hAlign = ((JLabel)c).getHorizontalAlignment();
vAlign = ((JLabel)c).getVerticalAlignment();
     }
     if(c instanceof AbstractButton) {
hAlign = ((AbstractButton)c).getHorizontalAlignment();
vAlign = ((AbstractButton)c).getVerticalAlignment();
     }
     background = c.getBackground();
     foreground = c.getForeground();
     font       = c.getFont();
   }
 
Example 18
Source File: TitledBorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 19
Source File: StyleEditor.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
public void preset(Component c, boolean dontColorize) {
  Color svb = getCurrStyle().background;
  Color svf = getCurrStyle().foreground;
  if(dontColorize) {
    getCurrStyle().background = c.getBackground();
    getCurrStyle().foreground = c.getForeground();      
  }
  setStyle(c, getCurrStyle());
  getCurrStyle().background = svb;
  getCurrStyle().foreground = svf;
}
 
Example 20
Source File: FlatWindowAbstractIcon.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
protected Color getForeground( Component c ) {
	return c.getForeground();
}