myrectaction.java~1~

来自「Java画版程序。......................要求变态。」· JAVA~1~ 代码 · 共 82 行

JAVA~1~
82
字号
package myshapeaction;/** * Title: * Description: * Copyright:    Copyright (c) 2002 * Company: * @author * @version 1.0 */import java.awt.event.*;import myshape.*;import java.math.*;import java.util.*;public class MyRectAction extends MyActionAdapter{  public MyRectAction() {  }  private boolean canDragged=false;  private MyPoint startPoint;  private MyPoint endPoint=null;  private MyRect rect;  public boolean mousePressed(MouseEvent e,Object o){     // System.out.print("lkdflskfd");     LinkedList l=(LinkedList)o;     if(!canDragged){        if(l.isEmpty()){          startPoint=new MyPoint(e.getX(),e.getY());        }        else{           startPoint=((MyShape)l.getFirst()).getPoint();        }        //startPoint.attachToOthers=true;        canDragged=true;        startPoint.setColor(startPoint.controlColor);        drawedItemList.add(startPoint);        rect=null;     }        return true;  }  public boolean mouseDragged(MouseEvent e,Object o){    if(canDragged  ){       endPoint=new MyPoint(e.getX(),e.getY());       //endPoint.attachToOthers=true;       if(!endPoint.nearTo(startPoint))        {         if(rect!=null){            drawedItemList.removeLast();            drawedItemList.removeLast();          }         endPoint.setColor(endPoint.controlColor);         rect=new MyRect(startPoint,endPoint);         drawedItemList.add(endPoint);         drawedItemList.add(rect);       }    }       return true;  }  public boolean mouseReleased(MouseEvent e,Object o){   //  System.out.print("lkdflskfd");      if(startPoint!=null ){       /* if(endPoint==null){          drawedItemList.removeLast();        }        else if(endPoint.nearTo(centerPoint)){          drawedItemList.removeLast();        }*/      startPoint=null;      canDragged=false;     }        return true;  }}

⌨️ 快捷键说明

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