⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ballworld1.java

📁 Java变的几个小程序
💻 JAVA
字号:
// BallWorld.java

          // indicate we wish to refer to AWT packages

          import java.awt.*;

          public class BallWorld extends Frame

          {

          ////////////////////////////////

          ////////// variables ///////////

          ////////////////////////////////

          // application variables

          private Ball myBall;

          ////////////////////////////////

          ///////////// methods //////////

          ////////////////////////////////

          ////////// method main ///////////

          // sequence of instrucions for main program

          static public void main (String [] args)

          {

          // create and display window for a new application object

          BallWorld world = new BallWorld ();

          world.show ();

          }

          ////////// method BallWorld ///////////

          private BallWorld ()

          {

          // set size and title of our application window

          setSize(600, 400);

          setTitle("Ball World");

          // make "myBall" a reference to a new instance of ball

          myBall = new Ball(100, 100, 50, 4, 5);

          }

          ////////// method paint ///////////

          // display things on graphic object "g"

          public void paint(Graphics g)

          {

          // display the ball

          myBall.paint( g );

          // wait a little while

          // (if your computer is fast/slow edit this pause length)

          pause( 2000 );

          // terminate program and close application window

          System.exit(0);

          }

          ////////// method pause ///////////

          // pause for a given number of milliseconds

          private void pause(int numMilliseconds)

          {

          // use a Java libary routine to pause a little

          try{ Thread.sleep( numMilliseconds ); } catch (InterruptedException e){}

          }

          } // class

⌨️ 快捷键说明

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