绘图五环

2021-11-23  本文已影响0人  哈迪斯Java

import javax.swing.;
import java.awt.
;

public class FiveCircle extends JFrame{
private final int OvalWidth=80;
private final int OvalHeight=80;
public FiveCircle(){
initialize();
}
private void initialize(){
setSize(300,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setContentPane(new DrawPane());
setTitle("奥运五环");
setVisible(true);
}
class DrawPane extends JPanel{
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawOval(10,10,OvalWidth,OvalHeight);
g.drawOval(80,10,OvalWidth,OvalHeight);
g.drawOval(150,10,OvalWidth,OvalHeight);
g.drawOval(50,70,OvalWidth,OvalHeight);
g.drawOval(120,70,OvalWidth,OvalHeight);
}
}

public static void main(String[] args) {
    FiveCircle fiveCircle = new FiveCircle();
}

}

上一篇 下一篇

猜你喜欢

热点阅读