nestedrectscontroller.java

来自「书籍"Java_面向事件编程"的附带光盘代码」· Java 代码 · 共 30 行

JAVA
30
字号
import objectdraw.*;import java.awt.*;// creates a set of NestedRects and allows them to be dragged or removed// according to the action of the mousepublic class NestedRectsController extends WindowController {    // dimensions of NestedRects    private static final double WIDTH = 200,                                HEIGHT = 100;    private NestedRects rects;    // draw a new set of NestedRects where the mouse was pressed    public void onMousePress(Location point) {        rects = new NestedRects( point.getX(), point.getY(),                                  WIDTH, HEIGHT, canvas );    }    // move the rects with the mouse    public void onMouseDrag(Location point) {        rects.moveTo(point.getX(), point.getY());    }        // remove the rects from the canvas    public void onMouseRelease(Location point) {        rects.removeFromCanvas();    }    }

⌨️ 快捷键说明

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