网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.J2EE和XML为企业应用软件创造机会.
.当主线程崩溃而其它线程继续运行.
.为apache加速.
.嵌入式开发技术前沿:仔细研究J2.
.用 WebSphere Studio 在 JMS 或 .
.Struts1.0学习文档-初学者入门.
.探索Application Server的世界.
.JDBC技术介绍.
.user itext create a word file.
.哪里去找支持中文的字体.
.专家和您一起谈谈java加壳的问题.
.PetStore 中EJB 的设计模式.
.设计模式的原则.
.多附件、带有预览功能的HTML页面.
.MVC 构架学习之渐行渐进(三).
.定制xDoclet标签自动生成框架配置.
.我眼中的Java经典书籍.
.配置JBoss4JDBC连接.
.使用JBuilder2007开发Web Servic.
.JasperReport经验谈.

java applet 画图板

发表日期:2008-1-5



  import Java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class HuaTu implements MouseMotionListener,ActionListener{
static final int r=3;
static int ox, oy;
static int flag=1;
public static void main(String arg[]){
JFrame f=new JFrame("Paint");
Container p=f.getContentPane();
p.setLayout(new FlowLayout());
JButton jButton1 = new JButton("红");
JButton jButton2 = new JButton("黑");
JButton jButton3 = new JButton("退出");
//Graphics g.setColor(new Color(255,0,0));
//ButtonEvent arg=new ButtonEvent(arg);
jButton1.addActionListener(new HuaTu());
jButton2.addActionListener(new HuaTu());
jButton3.addActionListener(new HuaTu());
p.addMouseMotionListener(new HuaTu());
p.add(jButton1);
p.add(jButton2);
p.add(jButton3);
f.setSize(200,200);
f.show();
}
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("红")){
flag=1;
}
else if (e.getActionCommand().equals("黑")){
flag=2;
}
else if (e.getActionCommand().equals("退出"))
System.exit(0);
}
public void mouseDragged(MouseEvent e){
Container c=(Container)e.getSource();
Graphics g=c.getGraphics();
if (ox>=0) {
if(flag==1){
g.setColor(new Color(168,0,255));
g.drawLine(ox,oy,e.getX(),e.getY());}
else
{ g.setColor(new Color(0,0,0));
g.drawLine(ox,oy,e.getX(),e.getY());}
}
ox=e.getX();oy=e.getY();
}
public void mouseMoved(MouseEvent e){
ox=-1;oy=-1;
}
}
上一篇:Java Applet的应用技巧(1) 人气:621
下一篇:Java 2源码解读:java.util.ArrayList 人气:821
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐