- 关于StatusbarBuilder的说明: 介绍API说明、设计思路以及当前存在的问题。
- SlightBevelBorder.java :SlightBevelBorder类源代码。
- StatusbarBuilder.java:StatusbarBuilder类源代码。
- TestStatusbar.java:测试程序
/*===============================================================================
* SlightBevelBorder.java
*===============================================================================
* auth: Jason
* CSDN ID: Unagain
* Email: tl21cen@hotmail.com
* date: 2006-4-11
*===============================================================================
*/
package tl.util;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.border.SoftBevelBorder;
public class SlightBevelBorder extends SoftBevelBorder {
private static final long serialVersionUID = 1L;
public SlightBevelBorder(int bevelType) {
super(bevelType);
}
public SlightBevelBorder(int bevelType, Color highlight, Color shadow) {
super(bevelType, highlight, shadow);
}
/**
* Paints the border for the specified component with the specified
* position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width,
int height) {
Color oldColor = g.getColor();
g.translate(x, y);
if (bevelType == RAISED) {
g.setColor(getHighlightOuterColor(c));
g.drawLine(0, 0, width - 2, 0);
g.drawLine(0, 1, 0, height - 2);
g.setColor(getShadowOuterColor(c));
g.drawLine(0, height - 1, width - 1, height - 1);
g.drawLine(width - 1, 0, width - 1, height - 1);
} else if (bevelType == LOWERED) {
g.setColor(getShadowOuterColor(c));
g.drawLine(0, 0, width - 2, 0);
g.drawLine(0, 0, 0, height - 2);
g.setColor(getHighlightOuterColor(c));
g.drawLine(0, height - 1, width - 1, height - 1);
g.drawLine(width - 1, 0, width - 1, height);
}
g.translate(-x, -y);
g.setColor(oldColor);
}
}