码迷,mamicode.com
首页 > 编程语言 > 详细

java工具类之Graphics

时间:2015-09-02 20:40:21      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:

利用重写paint()方法绘画出一个坐标轴:

package huaxian;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class huaxian2 extends JFrame {

    private JPanel jp;
    private JFrame jf;
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        huaxian2 h2 = new huaxian2();
    }
    
    public huaxian2(){
        
        this.setSize(500, 500);
        this.setVisible(true);
        this.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
        
        jp = new JPanel();
        this.add(jp);
        
    }
    
    @Override
    public void paint(Graphics g){
        super.paint(g);
        g.drawLine(50, 350, 498, 350);
        g.drawLine(50, 50, 50, 350);
    }
}

  点击运行结果:

技术分享

 

java工具类之Graphics

标签:

原文地址:http://www.cnblogs.com/xiangxi/p/4779281.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!