⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 线条作画.java

📁 200多个自己编的java程序,大家可以学一下.
💻 JAVA
字号:
/* * 线条作画.java * * Created on 2004年9月24日, 上午11:56 *//** * * @author  litertiger */import java.awt.*;import java.awt.event.*;public class 线条作画 extends java.applet.Applet implements ActionListener,MouseMotionListener {        /** Initialization method that will be called after the applet is loaded     *  into the browser.     */    int x=-1,y=-1;        int 橡皮擦通知 = 0;        int 清除通知 = 0;    Color c=new Color(255,0,0);    int con=3;Button b_red,b_green,清除,b_quit,b_blue;                public void init() {        addMouseMotionListener(this);        b_red=new Button("花红色图形");        b_green=new Button("画绿色图形");        b_blue=new Button("蓝色图形");        b_quit=new Button("橡皮");        清除=new Button("清除");        add(b_red);        add(b_green);        add(b_blue);        add(b_quit);        add(清除);        b_red.addActionListener(this);        b_blue.addActionListener(this);        b_green.addActionListener(this);        b_quit.addActionListener(this);        清除.addActionListener(this);        // TODO start asynchronous download of heavy resources    }    public void paint(Graphics g)    {           if(x!=-1&&y!=-1&&橡皮擦通知 == 0&&清除通知 == 0)        {               g.setColor(c);            g.fillOval(x, y,con,con);        }        else if(橡皮擦通知==1&&清除通知==0)        {            g.clearRect(x, y,10,10);        }                else if(橡皮擦通知==0&&清除通知==1)        {            g.clearRect(0, 0,getSize().width,getSize().height);                    }            }        public void mouseDragged(MouseEvent e) {        x=(int)e.getX();        y=(int)e.getY();        repaint();    }    public  void update(Graphics g)    {    paint(g);    }        public void mouseMoved(MouseEvent e) {    }            public void actionPerformed(ActionEvent e) {        if(e.getSource()==b_red)        {            橡皮擦通知=0;            清除通知=0;            c=new Color(255,0,0);        }            if(e.getSource()==b_green)        {            橡皮擦通知=0;            清除通知=0;            c=new Color(0,255,0);        }          if(e.getSource()==b_blue)        {            橡皮擦通知=0;            清除通知=0;            c=new Color(0,0,255);        }           if(e.getSource()==b_quit)        {            橡皮擦通知=1;            清除通知=0;                   }          if(e.getSource()==清除)        {            橡皮擦通知=0;            清除通知=1;            repaint();                    }    }        // TODO overwrite start(), stop() and destroy() methods}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -