资源简介
用Java模拟画图板,实现基本图形的绘画,并支持撤销、清空、重复功能,可提供颜色选择。。。
代码片段和文件信息
package lab14;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Myframe extends Jframe{
private JRadioButton linerectangleovalcurve;
private JRadioButton redblueblack;
private JButton jbt = new JButton(“Clear“);
private JButton undo = new JButton(“Undo“);
private JButton redo = new JButton(“Redo“);
private Paint paint = new Paint(); //画图的界面
private int type colorType;
private int x1x2y1y2;
public Myframe(){
JPanel jp1 = new JPanel();
jp1.setLayout(new GridLayout(101));
jp1.add(line = new JRadioButton(“Line“));
jp1.add(rectangle = new JRadioButton(“Rectangle“));
jp1.add(oval = new JRadioButton(“Oval“));
jp1.add(curve = new JRadioButton(“Curve“));
jp1.add(red = new JRadioButton(“Red“));
jp1.add(blue = new JRadioButton(“Blue“));
jp1.add(black = new JRadioButton(“Black“));
jp1.add(jbt);
jp1.add(undo);
jp1.add(redo);
ButtonGroup group1 = new ButtonGroup();
group1.add(line);
group1.add(rectangle);
group1.add(oval);
group1.add(curve);
ButtonGroup group2 = new ButtonGroup();
group2.add(red);
group2.add(blue);
group2.add(black);
setLayout(new BorderLayout());
add(jp1 BorderLayout.WEST);
add(paint BorderLayout.CENTER);
paint.addMouseListener(new PressListener());
paint.addMouseMotionListener(new DragListener());
line.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
type = 1;
}
});
rectangle.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
type = 2;
}
});
oval.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
type = 3;
}
});
curve.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
type = 4;
}
});
red.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
colorType = 1;
//paint.setColor(colorType);
}
});
blue.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
colorType = 2;
//paint.setColor(colorType);
}
});
black.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
colorType = 0;
//paint.setColor(colorType);
}
});
jbt.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
paint.setIsClear(true);
paint.repaint();
paint.clear();
}
});
undo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
paint.undo();
paint.repaint();
}
});
redo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
paint.redo();
paint.repaint();
}
});
}
public static void main(String[] args){
Myframe frame = new Myframe();
frame.settitle(“Painter“);
frame.setLocationRelativeTo(null);
fr 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 232 2008-12-18 18:27 lab14\.classpath
文件 381 2008-12-18 18:27 lab14\.project
文件 662 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 744 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 662 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 662 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 662 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 662 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 662 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 662 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 788 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 742 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 981 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 1033 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 4150 2009-10-06 09:35 lab14\bin\lab14\Myfr
文件 3990 2009-10-06 09:35 lab14\bin\lab14\Paint.class
文件 3566 2008-12-18 23:26 lab14\src\lab14\Myfr
文件 3949 2008-12-21 12:40 lab14\src\lab14\Paint.java
目录 0 2009-10-06 09:35 lab14\bin\lab14
目录 0 2008-12-18 18:28 lab14\src\lab14
目录 0 2009-10-06 09:35 lab14\bin
目录 0 2008-12-18 18:27 lab14\src
目录 0 2008-12-18 18:27 lab14
----------- --------- ---------- ----- ----
25190 23
- 上一篇:spring-web.jar
- 下一篇:JAVA实现的网络白板
相关资源
- java图片浏览器跨平台运行程序与源码
- 基于java的在线考试系统-毕业设计
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
川公网安备 51152502000135号
评论
共有 条评论