public static void drawText(Graphics g, ChoiceState s) {
String text = s.getText();
if (text == null) {
return;
}
Rectangle r = s.getTextBounds();
Shape oldClip = g.getClip();
g.clipRect(r.x, r.y, r.width, r.height);
g.setFont(s.getFont());
g.setColor(s.isFocused() ? SystemColor.textHighlightText
: s.getTextColor());
int baseX = r.x;
int baseY = r.y + r.height - s.getFontMetrics().getDescent();
if (s.isEnabled()) {
g.drawString(text, baseX, baseY);
} else {
drawDisabledString(g, text, baseX, baseY);
}
g.setClip(oldClip);
}
java类java.awt.SystemColor的实例源码
DefaultChoice.java 文件源码
项目:cn1
阅读 18
收藏 0
点赞 0
评论 0
DefaultFileDialog.java 文件源码
项目:cn1
阅读 16
收藏 0
点赞 0
评论 0
public boolean show() {
if (!shown) {
fileDialog.setBackground(SystemColor.control);
// create components & add listeners here
createComponents();
addLayoutComponents();
addListeners();
fileDialog.setSize(SIZE, SIZE);
String file = fileDialog.getFile();
File curFile = ((file != null) ? new File(file) : null);
File curFolder = ((curFile != null) ?
curFile.getParentFile() : getDefaultFolder());
changeDirectory(curFolder);
if (curFile != null) {
fileName.setText(file);
}
fillChoice();
shown = true;
}
return true; // call Dialog's show()
}
DefaultScrollbar.java 文件源码
项目:cn1
阅读 16
收藏 0
点赞 0
评论 0
private static void paintTriangle(final Graphics g, final int[] x, final int[] y,
final boolean isEnabled) {
g.setColor(isEnabled ? arrowColor : SystemColor.controlShadow);
g.fillPolygon(new Polygon(x, y, x.length));
if (!isEnabled) {
g.setColor(SystemColor.controlHighlight);
int x1 = x[0] + 1;
int y1 = y[0] + 1;
int x2 = x[1] + 1;
int y2 = y[1] + 1;
g.drawLine(x1, y1, x2, y2);
}
}
DefaultList.java 文件源码
项目:cn1
阅读 18
收藏 0
点赞 0
评论 0
private static void drawItem(int idx, Graphics g, ListState s) {
Rectangle itemRect = s.getItemBounds(idx);
itemRect.width = s.getClient().width - itemRect.x + 1;
int itemHeight = itemRect.height;
if (s.isSelected(idx)) {
g.setColor(SystemColor.textHighlight);
((Graphics2D)g).fill(itemRect);
g.setColor(SystemColor.textHighlightText);
}
String item = s.getItem(idx);
FontMetrics fm = s.getFontMetrics();
int baseLineOffset = itemHeight - fm.getDescent() - 1;
g.drawString(item, itemRect.x + 1, baseLineOffset + itemRect.y);
if (s.isSelected(idx)) {
g.setColor(s.getTextColor());
}
}
DefaultButton.java 文件源码
项目:cn1
阅读 19
收藏 0
点赞 0
评论 0
public static void drawBackground(Graphics g, ButtonState s) {
Rectangle rect = s.getBounds();
Color bkColor = s.isBackgroundSet() ? s.getBackground() :
SystemColor.control;
g.setColor(bkColor);
g.fillRect(0, 0, rect.width, rect.height);
drawButtonFrame(g, s.getBounds(), s.isPressed());
if (s.isFocused()) {
Color foreColor = s.isTextColorSet() ?
s.getTextColor() :
SystemColor.controlText;
g.setColor(foreColor);
drawFocusRect(g, 3, 3, rect.width - 7, rect.height - 7);
}
}
DefaultButton.java 文件源码
项目:cn1
阅读 20
收藏 0
点赞 0
评论 0
public static void drawButtonFrame(Graphics g, Rectangle rect, boolean pressed) {
if (pressed) {
g.setColor(SystemColor.controlHighlight);
g.drawLine(rect.width - 1, 0, rect.width - 1, rect.height - 1);
g.drawLine(0, rect.height - 1, rect.width - 1, rect.height - 1);
g.setColor(SystemColor.controlShadow);
g.drawLine(1, 1, rect.width - 3, 1);
g.drawLine(1, 1, 1, rect.height - 3);
g.setColor(SystemColor.controlDkShadow);
g.drawLine(0, 0, rect.width - 2, 0);
g.drawLine(0, 0, 0, rect.height - 2);
} else {
g.setColor(SystemColor.controlHighlight);
g.drawLine(0, 0, rect.width - 1, 0);
g.drawLine(0, 0, 0, rect.height - 1);
g.setColor(SystemColor.controlShadow);
g.drawLine(rect.width - 2, 1, rect.width - 2, rect.height - 2);
g.drawLine(1, rect.height - 2, rect.width - 2, rect.height - 2);
g.setColor(SystemColor.controlDkShadow);
g.drawLine(rect.width - 1, 0, rect.width - 1, rect.height - 1);
g.drawLine(0, rect.height - 1, rect.width - 1, rect.height - 1);
}
}
DefaultCheckbox.java 文件源码
项目:cn1
阅读 23
收藏 0
点赞 0
评论 0
private static void drawPressedRect(Graphics g, Rectangle rect,
boolean pressed) {
int w = rect.width;
int h = rect.height;
int x = rect.x;
int y = rect.y;
g.setColor(SystemColor.controlHighlight);
g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
g.setColor(SystemColor.controlShadow);
g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
g.setColor(SystemColor.controlDkShadow);
g.drawLine(x, y, x + w - 2, y);
g.drawLine(x, y, x, y + h - 2);
g.setColor(pressed ? pressedColor : SystemColor.window);
g.fillRect(x+2, y+2, CB_SIZE - 2, CB_SIZE - 2);
}
DefaultCheckbox.java 文件源码
项目:cn1
阅读 17
收藏 0
点赞 0
评论 0
private static void drawPressedCircle(Graphics g, Rectangle rect,
boolean pressed) {
int w = rect.width;
int h = rect.height;
int x = rect.x;
int y = rect.y;
g.setColor(SystemColor.controlShadow);
int startAngle = 45;
int angle = 180;
int endAngle = startAngle + angle;
g.drawArc(x, y, w, h, startAngle, angle);
g.setColor(SystemColor.controlDkShadow);
g.drawArc(x + 1, y + 1, w - 1, h - 1, startAngle, angle);
g.setColor(SystemColor.controlHighlight);
g.drawArc(x, y, w, h, endAngle, angle);
g.setColor(SystemColor.controlLtHighlight);
g.drawArc(x + 1, y + 1, w - 1, h - 1, endAngle, angle);
g.setColor(pressed ? pressedColor : SystemColor.window);
g.fillOval(x+2, y+2, CB_SIZE - 2, CB_SIZE - 2);
}
TipUtil.java 文件源码
项目:ESPlorer
阅读 20
收藏 0
点赞 0
评论 0
/**
* Returns the default background color to use for tool tip windows.
*
* @return The default background color.
*/
public static Color getToolTipBackground() {
Color c = UIManager.getColor("ToolTip.background");
// Tooltip.background is wrong color on Nimbus (!)
boolean isNimbus = isNimbusLookAndFeel();
if (c==null || isNimbus) {
c = UIManager.getColor("info"); // Used by Nimbus (and others)
if (c==null || (isNimbus && isDerivedColor(c))) {
c = SystemColor.info; // System default
}
}
// Workaround for a bug (?) with Nimbus - calling JLabel.setBackground()
// with a ColorUIResource does nothing, must be a normal Color
if (c instanceof ColorUIResource) {
c = new Color(c.getRGB());
}
return c;
}