JAVA画图
2011-10-09 13:36
204 查看
package gui; import java.awt.*; import java.awt.event.*; public class PaintFrame extends Frame { private static final long serialVersionUID = 1L; private int _x, _y, x, y; private boolean bps = false; public void paint(Graphics g) { if (bps) { Color c = g.getColor(); g.setColor(Color.RED); g.drawLine(_x, _y, x, y); g.setColor(c); } } public PaintFrame() { this.setBounds(230, 100, 600, 500); this.setTitle("画图"); this.setResizable(false); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); this.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { _x = e.getX(); _y = e.getY(); } public void mouseReleased(MouseEvent e) { bps = false; } }); this.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent arg0) { bps = true; } public void mouseDragged(MouseEvent e) { x = e.getX(); y = e.getY(); PaintFrame.this.paint(PaintFrame.this.getGraphics()); _x = x; _y = y; } }); this.setVisible(true); } public static void main(String[] args) { new PaintFrame(); } }
相关文章推荐
- 图说java反射续 建议下载图,用画图打开
- Java应用---Design for Coder(集截屏,取色,放大,画图)为一体
- 利用java画图向前端输出验证码图片
- 黑马程序员--java基础 GUI画图学习日志
- Java矢量画图工具
- JAVA 画图板实现(基本画图功能+界面UI)一、界面实现
- JAVA画图中反锯齿
- java-gui初步-在窗口中画图
- java的Swing编程====实现鼠标双击一下==画图===getMouseClicked的方法
- Java画图程序设计
- Java面向对象深入学习:制作一个画图工具并计算那些图形的面积和周长。
- javaweb-day04-4(javaWeb开发入门 - 画图演示:浏览器访问服务器的静态web资源的过程)
- Java学习笔记(四):窗体和画图
- java例程练习(简单的画图程序[鼠标事件处理])
- jsp向页面显示图片,找不到文件时直接使用java画图
- Java画图满天星
- Java图形界面-画图程序
- Java 对象的多态性——必须画图理解
- JAVA 画图机制
- linux tomcat部署含有matlab画图打包的java web程序