scrollingsun.java

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

JAVA
22
字号
import objectdraw.*;import java.awt.*;    // A program that produces an animation of the sun rising and setting.    // The animation is driven by dragging the mouse.public class ScrollingSun extends WindowController {    private FilledOval sun;  // Circle that represents the sun        // Place the sun and some brief instructions on the screen    public void begin() {        sun = new FilledOval( 50, 150, 100, 100, canvas);        new Text( "Drag the mouse up or down", 20, 30, canvas );    }        // Move the sun to follow the mouse's vertical motion    public void onMouseDrag( Location mousePosition ) {        sun.moveTo( 50, mousePosition.getY() );    }}

⌨️ 快捷键说明

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