⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 curvedborder.java

📁 java swing 开发代码
💻 JAVA
字号:
// CurvedBorder.java// A custom border that draws round rectangle borders.//package	jswing.ch13;import java.awt.*;import javax.swing.border.*;public class CurvedBorder extends AbstractBorder{    private Color wallColor = Color.gray;    private int sinkLevel = 10;    public CurvedBorder() { }    public CurvedBorder(int sinkLevel) { this.sinkLevel = sinkLevel; }    public CurvedBorder(Color wall) { this.wallColor = wall; }    public CurvedBorder(int sinkLevel, Color wall)    {        this.sinkLevel = sinkLevel;        this.wallColor = wall;    }    public void paintBorder(Component c, Graphics g, int x, int y,                            int w, int h)    {        g.setColor(getWallColor());        //  Paint a tall wall around the component        for (int i = 0; i < sinkLevel; i++) {           g.drawRoundRect(x+i, y+i, w-i-1, h-i-1, sinkLevel-i, sinkLevel);           g.drawRoundRect(x+i, y+i, w-i-1, h-i-1, sinkLevel, sinkLevel-i);           g.drawRoundRect(x+i, y, w-i-1, h-1, sinkLevel-i, sinkLevel);           g.drawRoundRect(x, y+i, w-1, h-i-1, sinkLevel, sinkLevel-i);        }    }    public Insets getBorderInsets(Component c) {        return new Insets(sinkLevel, sinkLevel, sinkLevel, sinkLevel);    }    public Insets getBorderInsets(Component c, Insets i) {        i.left = i.right = i.bottom = i.top = sinkLevel;        return i;    }    public boolean isBorderOpaque() { return true; }    public int getSinkLevel() { return sinkLevel; }    public Color getWallColor() { return wallColor; }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -