public class View {
public static void main(String[] args) {
new MyFrame().init();
}
}
class MyFrame extends Frame{
void init(){
//初始化框架
setSize(400, 500);
//将容器放在框架上 获得容纳面板
//做其他事情
Do();
//设置窗口可视化
setVisible(true);
//设置点击'x'关闭窗口程序
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
//画笔
@Override
public void paint(Graphics g) {
//画笔需要有颜色,可以画画
g.setColor(Color.red);
g.fillOval(100,100,100,100);//实心圆
//g.drawOval(100,100,100,100);
// g.setColor(Color.GREEN);
g.fillRect(150,200,200,200);
//养成习惯,画笔用完,还原为最初的颜色
}
void Do(){
}
}
标签:200,画笔,void,Override,100,public From: https://www.cnblogs.com/geeklee/p/17289005.html