1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. 實現鼠標畫圖的Java程序

        時間:2024-06-22 21:59:27 JAVA認證 我要投稿
        • 相關推薦

        實現鼠標畫圖的Java程序

          用鼠標畫圖有很多樂趣和便利之處,那么如何才能實現鼠標畫圖呢?下面YJBYS小編為大家整理了關于實現鼠標畫圖的Java程序,希望對你有所幫助。

        實現鼠標畫圖的Java程序

          import java.awt.Color;

          import java.awt.Frame;

          import java.awt.Graphics;

          import java.awt.Point;

          import java.awt.event.MouseAdapter;

          import java.awt.event.MouseEvent;

          import java.awt.event.MouseListener;

          import java.util.ArrayList;

          import java.util.Iterator;

          public class MyMouseAdapter {

          public static void main(String[] args) {

          new MyFrame5(“drawing”);

          class MyFrame5 extends Frame{

          ArrayList points=null;

          MyFrame5(String s){

          super(s);

          points=new ArrayList();

          setLayout(null);

          setBounds(300,300,400,300);

          this.setBackground(new Color(204,204,255));

          setVisible(true);

          this.addMouseListener(new Monitor5());

          }

          public void paint(Graphics g){

          Iterator i=points.iterator();

          while(i.hasNext()){

          Point p=(Point)i.next();

          g.setColor(Color.blue);

          g.fillOval(p.x,p.y, 10, 10);

          }

          }

          public void addPoint(Point p){

          points.add(p);

          }

          }

          class Monitor5 extends MouseAdapter{ //MouseAdapter實現了MouseListener接口

          public void mousePressed(MouseEvent e){

          MyFrame5 f=(MyFrame5)e.getSource();

          f.addPoint(new Point(e.getX(),e.getY()));

          f.repaint(); //讓Frame強制經行重畫

          }

          }

        【實現鼠標畫圖的Java程序】相關文章:

        如何編譯java程序03-05

        Java多線程的實現方式03-20

        Java程序開發與運行環境03-05

        Java如何實現簡單的whois查詢03-16

        Java語言的特點和實現機制02-27

        Java byte[]轉int如何實現03-16

        Java動態代理實現AOP的方法03-16

        AutoCAD繪圖時鼠標中鍵無法實現平移操作03-20

        sun認證java程序員須知Java日志框架03-30

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>