本文整理汇总了Java中java.awt.Component.getBackground方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getBackground方法的具体用法?Java Component.getBackground怎么用?Java Component.getBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Component
的用法示例。
在下文中一共展示了Component.getBackground方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adaptColorSchemePreviewComponent
import java.awt.Component; //导入方法依赖的package包/类
private void adaptColorSchemePreviewComponent(ColorScheme colorScheme, Component comp, int index) {
nameLabel.setText(colorScheme.getName());
List<ColorRGB> colors = colorScheme.getColors();
int colorCount = colors.size();
Color background = comp.getBackground();
for (int i = 0; i < colorPanels.length; ++i) {
if (i < colorCount) {
Color cColor = ColorRGB.convertToColor(colors.get(i));
colorPanels[i].setBackground(cColor);
} else {
colorPanels[i].setBackground(background);
}
}
colorSchemeComponent.setBackground(background);
colorPanel.setBackground(background);
}
示例2: deriveEmphColor
import java.awt.Component; //导入方法依赖的package包/类
private static Color deriveEmphColor(Component component) {
// derive the color for emphasizing from background
Color backColor = component.getBackground();
Color emphColor;
int backBrightness = (30*backColor.getRed()+59*backColor.getGreen()+11*backColor.getBlue())/100;
if (backBrightness >= 128) {
emphColor = backColor.darker();
} else { // brightening a dark area seems visually less notable than darkening a bright area
emphColor = backColor.brighter().brighter();
}
return emphColor;
}
示例3: paintIcon
import java.awt.Component; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y)
{
Color color = c == null ? Color.GRAY : c.getBackground();
// In a compound sort, make each succesive triangle 20%
// smaller than the previous one.
int dx = (int) (size / 2.0d * Math.pow(0.8, priority));
int dy = descending ? dx : -dx;
// Align icon (roughly) with font baseline.
y = y + 5 * size / 6 + (descending ? -dy : 0);
int shift = descending ? 1 : -1;
g.translate(x, y);
// Right diagonal.
g.setColor(color.darker());
g.drawLine(dx / 2, dy, 0, 0);
g.drawLine(dx / 2, dy + shift, 0, shift);
// Left diagonal.
g.setColor(color.brighter());
g.drawLine(dx / 2, dy, dx, 0);
g.drawLine(dx / 2, dy + shift, dx, shift);
// Horizontal line.
if( descending )
{
g.setColor(color.darker().darker());
}
else
{
g.setColor(color.brighter().brighter());
}
g.drawLine(dx, 0, 0, 0);
g.setColor(color);
g.translate(-x, -y);
}
示例4: paintBorder
import java.awt.Component; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Color color = c.getBackground();
if (origColor != color) {
origColor = color;
paintColor = new Color(~origColor.getRGB());
}
g.setColor(paintColor);
BasicGraphicsUtils.drawDashedRect(g, x, y, width, height);
}
示例5: paintBorder
import java.awt.Component; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
{
// choose which colors we want to use
Color bg = c.getBackground();
if (c.getParent() != null)
{
bg = c.getParent().getBackground();
}
if (bg != null)
{
Color mid = bg.darker();
Color edge = average(mid, bg);
g.setColor(bg);
g.drawLine(0, h - 2, w, h - 2);
g.drawLine(0, h - 1, w, h - 1);
g.drawLine(w - 2, 0, w - 2, h);
g.drawLine(w - 1, 0, w - 1, h);
// draw the drop-shadow
g.setColor(mid);
g.drawLine(1, h - 2, w - 2, h - 2);
g.drawLine(w - 2, 1, w - 2, h - 2);
g.setColor(edge);
g.drawLine(2, h - 1, w - 2, h - 1);
g.drawLine(w - 1, 2, w - 1, h - 2);
}
}
示例6: paintBorder
import java.awt.Component; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
// choose which colors we want to use
Color bg = c.getBackground();
if (c.getParent() != null) {
bg = c.getParent().getBackground();
}
if (bg != null) {
Color mid = bg.darker();
Color edge = average(mid, bg);
g.setColor(bg);
g.drawLine(0, h - 2, w, h - 2);
g.drawLine(0, h - 1, w, h - 1);
g.drawLine(w - 2, 0, w - 2, h);
g.drawLine(w - 1, 0, w - 1, h);
// draw the drop-shadow
g.setColor(mid);
g.drawLine(1, h - 2, w - 2, h - 2);
g.drawLine(w - 2, 1, w - 2, h - 2);
g.setColor(edge);
g.drawLine(2, h - 1, w - 2, h - 1);
g.drawLine(w - 1, 2, w - 1, h - 2);
}
}
示例7: paintIcon
import java.awt.Component; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Color color = c == null ? Color.GRAY : c.getBackground();
// In a compound sort, make each succesive triangle 20%
// smaller than the previous one.
int dx = (int) (size / 2 * Math.pow(0.8, priority));
int dy = descending ? dx : -dx;
// Align icon (roughly) with font baseline.
y = y + 5 * size / 6 + (descending ? -dy : 0);
int shift = descending ? 1 : -1;
g.translate(x, y);
// Right diagonal.
g.setColor(color.darker());
g.drawLine(dx / 2, dy, 0, 0);
g.drawLine(dx / 2, dy + shift, 0, shift);
// Left diagonal.
g.setColor(color.brighter());
g.drawLine(dx / 2, dy, dx, 0);
g.drawLine(dx / 2, dy + shift, dx, shift);
// Horizontal line.
if (descending) {
g.setColor(color.darker().darker());
} else {
g.setColor(color.brighter().brighter());
}
g.drawLine(dx, 0, 0, 0);
g.setColor(color);
g.translate(-x, -y);
}
示例8: paintIcon
import java.awt.Component; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
Color color = c == null ? Color.GRAY
: c.getBackground();
// In a compound sort, make each succesive triangle 20%
// smaller than the previous one.
int dx = (int) (size / 2 * Math.pow(0.8, priority));
int dy = descending ? dx
: -dx;
// Align icon (roughly) with font baseline.
y = y + 5 * size / 6 + (descending ? -dy
: 0);
int shift = descending ? 1
: -1;
g.translate(x, y);
// Right diagonal.
g.setColor(color.darker());
g.drawLine(dx / 2, dy, 0, 0);
g.drawLine(dx / 2, dy + shift, 0, shift);
// Left diagonal.
g.setColor(color.brighter());
g.drawLine(dx / 2, dy, dx, 0);
g.drawLine(dx / 2, dy + shift, dx, shift);
// Horizontal line.
if (descending) {
g.setColor(color.darker().darker());
} else {
g.setColor(color.brighter().brighter());
}
g.drawLine(dx, 0, 0, 0);
g.setColor(color);
g.translate(-x, -y);
}
示例9: paintIcon
import java.awt.Component; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
Color color = c == null ? Color.gray
: c.getBackground();
// In a compound sort, make each succesive triangle 20%
// smaller than the previous one.
int dx = (int) (size / 2 * Math.pow(0.8, priority));
int dy = descending ? dx
: -dx;
// Align icon (roughly) with font baseline.
y = y + 5 * size / 6 + (descending ? -dy
: 0);
int shift = descending ? 1
: -1;
g.translate(x, y);
// Right diagonal.
g.setColor(color.darker());
g.drawLine(dx / 2, dy, 0, 0);
g.drawLine(dx / 2, dy + shift, 0, shift);
// Left diagonal.
g.setColor(color.brighter());
g.drawLine(dx / 2, dy, dx, 0);
g.drawLine(dx / 2, dy + shift, dx, shift);
// Horizontal line.
if (descending) {
g.setColor(color.darker().darker());
} else {
g.setColor(color.brighter().brighter());
}
g.drawLine(dx, 0, 0, 0);
g.setColor(color);
g.translate(-x, -y);
}