credit.java

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

JAVA
29
字号
import objectdraw.*;import java.awt.*;public class Credit extends ActiveObject {    private static final int Y_SPEED = 4;    private static final int DELAY_TIME = 100;        private Text roleAndName; // information to be displayed        public Credit(String scrollingLine, DrawingCanvas canvas) {        // create the line to be displayed        roleAndName = new Text(scrollingLine, 0, canvas.getHeight(), canvas);        // center it on the canvas        roleAndName.move((canvas.getWidth() - roleAndName.getWidth())/2, 0);        // start the movement        start();    }        public void run() {        // move up while any part of the credit line is visible        while (roleAndName.getY() > -roleAndName.getHeight()) {            roleAndName.move(0, -Y_SPEED);            pause(DELAY_TIME);        }        roleAndName.removeFromCanvas();    }}

⌨️ 快捷键说明

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