GUI_TestPaintComponent

来源:互联网 发布:网络借贷p2p系统 编辑:程序博客网 时间:2024/05/01 15:11
import javax.swing.*;import java.awt.Graphics;public class TestPaintComponent extends JFrame{public TestPaintComponent(){add(new NewPanel());}public static void main(String[] agrs){TestPaintComponent frame=new TestPaintComponent();frame.setTitle("TestPsintComponent");frame.setSize(200,100);frame.setLocationRelativeTo(null);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);}}class NewPanel extends JPanel{protected void paintComponent(Graphics g){super.paintComponent(g);g.drawLine(50, 50, 70, 70);//直线g.drawString("Banner", 40, 40);//字符位置、g.drawRect(0, 0, 200, 100);//矩形g.drawRoundRect(300, 300, 50, 100, 50, 50);g.draw3DRect(70, 70, 100, 50, true);}}

0 0
原创粉丝点击