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

The following examples show how to use java.awt.Component#getForeground() . These examples are extracted from open source projects. 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 Project: netbeans   File: TimelineHeaderRenderer.java    License: 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 2
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 Project: pumpernickel   File: TriangleIcon.java    License: 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 4
private void applyDimmer(boolean brighten, JPanel panel)
{
	for (Component component : panel.getComponents())
	{
		Color color = component.getForeground();

		component.setForeground(brighten ? color.brighter() : color.darker());
	}
}
 
Example 5
Source Project: pdfxtk   File: StyleEditor.java    License: 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 6
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 7
Source Project: pdfxtk   File: StyleEditor.java    License: 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 8
private void applyDimmer(boolean brighten, JPanel panel)
{
	for (Component component : panel.getComponents())
	{
		Color color = component.getForeground();

		component.setForeground(brighten ? color.brighter() : color.darker());
	}
}
 
Example 9
Source Project: JDKSourceCode1.8   File: TitledBorder.java    License: 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 10
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 11
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 12
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 13
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 14
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 15
Source Project: Java8CN   File: TitledBorder.java    License: 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 16
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 17
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 18
private Color getColor(Component c) {
    Color color = getTitleColor();
    if (color != null) {
        return color;
    }
    return (c != null)
            ? c.getForeground()
            : null;
}
 
Example 19
Source Project: pumpernickel   File: PaletteUI.java    License: 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 20
Source Project: FlatLaf   File: FlatWindowAbstractIcon.java    License: Apache License 2.0 4 votes vote down vote up
protected Color getForeground( Component c ) {
	return c.getForeground();
}