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

📄 handlequit.java

📁 《Java课程设计》第二版
💻 JAVA
字号:
import java.util.*;
import java.awt.event.*;
public class HandleQuit implements ActionListener{
    HandleMouse handleMouse;
    Point [] point;
    HandleQuit(HandleMouse handleMouse){
        this.handleMouse=handleMouse;
    }
    public void setPoint(Point [] p){
        point=p;
    }
    public void actionPerformed(ActionEvent e){
       ArrayList<Integer> step=handleMouse.getStep();
       int length=step.size();
       int start=-1,end=-1;
       if(length>=2){
          end=step.get(length-1);
          start=step.get(length-2);
          step.remove(length-1);
          step.remove(length-2);
          Animal ani=point[end].getThisAnimal();
          int w=ani.getBounds().width;
          int h=ani.getBounds().height; 
          ani.setLocation(point[start].getX()-w/2,point[start].getY()-h);
          ani.setAtPoint(point[start]);  
          point[start].setThisAnimal(ani);
          point[start].setIsHaveAnimal(true);       
          point[end].setIsHaveAnimal(false);
       }
    }
}

⌨️ 快捷键说明

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