用Java实现的Status Bar (1/3) - SlightBevelBorder.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);

    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值