标签:
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); } }
标签:
原文地址:http://www.cnblogs.com/AndyHoo/p/5341406.html