使用java画边角为圆弧的多边形

效果图:

使用java画边角为圆弧的多边形_第1张图片

/**
 * 本类用java画图,画一个矩形,四个角为半圆
 * @author liu
 *
 */
public class WriteCurve extends JFrame{
	 
    public static void main(String[] args) {
    	
    	WriteCurve test=new WriteCurve();
    	test.setSize(200, 200);
    	test.add(new T(1));
    	test.show();
    }
}
 
class T extends JLabel {
	int i;
    public T(int i) {
    	this.i=i;
    }
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.drawLine(30, 20, 70, 20);
        g.drawLine(20, 30, 20, 70);
        g.drawLine(30, 80, 70, 80);
        g.drawLine(80, 30, 80, 70);
        g.drawArc(20, 20, 20, 20, 90, 90);
        g.drawArc(60, 20, 20, 20, 0, 90);
        g.drawArc(20, 60, 20, 20, 180, 90);
        g.drawArc(60, 60, 20, 20, 270, 90);
    }
}

你可能感兴趣的:(使用java画边角为圆弧的多边形)