rectmover.java

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

JAVA
37
字号
import objectdraw.*;// class to animate the vertical motion of members of a// collection of FilledRectspublic class RectMover extends ActiveObject {        // the delay between moves    private final double DELAY = 400;        // the collection whose rects should be moved    private RectCollection theRects;        // how far to move in one step    private double dropSize;        // create an ActiveObject to slowly move all the rectangles    // in a collection up or down on the screen    public RectMover (RectCollection rects, double dy) {        dropSize = dy;        theRects = rects;        start();    }        public void run() {                while (true){                        theRects.goToFirst();            while ( theRects.rectsLeft() ){                theRects.getNextRect().move(0,dropSize);                pause( DELAY);            }                    }    }}

⌨️ 快捷键说明

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