浏览 1943 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-10-31
我的添加阴影的方法是:protected void fillShape(Graphics graphics) { /** don't modify the r directly */ Rectangle r = getBounds(); Rectangle.SINGLETON.setBounds(r); Rectangle.SINGLETON.y -= 1; Rectangle.SINGLETON.width += 1; Rectangle.SINGLETON.height += 1; int shadowDepth = 10; int rectangleWidth = r.width - shadowDepth; int rectangleHeight = r.height -shadowDepth; Color foreground = graphics.getForegroundColor(); Color background = graphics.getBackgroundColor(), shadow = ColorUtilities.darker(foreground); int x = r.x + shadowDepth; int y = r.y + shadowDepth; /** * trace shadow */ for (int i = shadowDepth - 1; i >= 0; i--) { shadow = lighter(background, i, shadowDepth); graphics.setBackgroundColor(shadow); graphics.fillRectangle(x, y, rectangleWidth, rectangleHeight); if (i > 0) { x--; if (fillBottom) y--; } } graphics.setBackgroundColor(background); graphics.setForegroundColor(foreground); graphics.fillRectangle(x, y, rectangleWidth, rectangleHeight); } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |