randomlybouncingballs.java
来自「书籍"Java_面向事件编程"的附带光盘代码」· Java 代码 · 共 38 行
JAVA
38 行
import java.awt.*;import objectdraw.*;// A class to draw a bunch of basketballs on the screen so// that by clicking we can watch them bounce randomlypublic class RandomlyBouncingBalls extends WindowController{ // all the balls displayed. private BallCollection allTheBalls; // create the balls as soon as the program starts public void begin() { allTheBalls = new BallCollection( canvas ); } // create an active object to bounce them when clicked. public void onMouseClick( Location point ) { new Bouncer( allTheBalls ); } // hide all the balls when the mouse leaves public void onMouseExit( Location point ) { allTheBalls.hide(); } // show all the balls when the mouse arrives public void onMouseEnter( Location point ) { allTheBalls.show(); } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?