本文主要是介绍GUI编程08:画笔paint,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本节内容视频链接:10、画笔paint_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV1DJ411B75F?p=10&vd_source=b5775c3a4ea16a5306db9c7c1c1486b5
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);}//窗口画笔工具@Overridepublic 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() {@Overridepublic void windowClosing(WindowEvent e) {System.exit(0);}});}
}
这篇关于GUI编程08:画笔paint的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!