package com.yundait.lesson03;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class TestPaint {
public static void main(String[] args) {
myPaint myPaint = new myPaint();
myPaint.loadFrame();
myPaint.closeWindows();
}
}
class myPaint extends Frame {
//加载窗口
public void loadFrame(){
setBounds(300,300,600,500);
setVisible(true);
}
//窗口画笔工具
@Override
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.red);
g.drawOval(100,100,100,100);
g.fillOval(300,300,100,100);
g.setColor(Color.green);
g.fillRect(200,200, 100,200);
}
//监听窗口关闭
public void closeWindows(){
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
GUI编程08:画笔paint
最新推荐文章于 2024-09-08 20:08:56 发布