首页 > 编程语言 > 详细

Java GUI 画点

时间:2016-03-31 16:53:47      阅读:271      评论:0      收藏:0      [点我收藏+]

技术分享

import java.awt.EventQueue;


public class Paint {

    private JFrame frame;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Paint window = new Paint();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public Paint() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.getContentPane().addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseDragged(MouseEvent e) {
                
                Graphics g = frame.getGraphics();
//                g.drawLine(0,0, e.getX(), e.getY());
                g.fillRect(e.getX()+7, e.getY()+30, 3, 3);
            }
        });
        frame.setBounds(100, 100, 450, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

 

Java GUI 画点

原文:http://www.cnblogs.com/AndyHoo/p/5341406.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!