Java GUI 画点
2016-03-31 15:37
573 查看
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.setColor(Color.BLUE);
// 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); } }
相关文章推荐
- 【hdu1242】Rescue——bfs+小根堆
- QML QuickItem鼠标键盘处理
- sql自动uuid,导表exp,imp指令
- EasyUI——DateBox和DateTimeBox的汉化和显示格式修改
- 96. Unique Binary Search Trees
- 回归基础系列-call by value / call by reference区别与实例
- LValue RValue
- hdu 2604 Queuing【递推+矩阵快速幂】
- ${pageContext.request.contextPath} JSP路径问题
- 多线程实现Thread.Start()与ThreadPool.QueueUserWorkItem两种方式对比
- YTKKeyValueStore用法
- 【poj 1019】Number Sequence
- Java中的String、StringBuffer和StringBuilder区别
- GCD的同步异步串行并行、NSOperation和NSOperationQueue一级用dispatch_once实现单例
- [Form Builder]:CREATE_GROUP Built-in
- 并发队列ConcurrentLinkedQueue和阻塞队列LinkedBlockingQueue用法
- String.valueOf()的一个坑—“null”
- 对Map类分别按照Key,Value排序,返回值为List对象
- iOS之NSPredicate(正则表达式和UIBarController)
- Vue.js 添加组件