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

📄 appletlife.java

📁 Java程序设计实用教程源代码 本书源代码按章分别放置在不同的文件夹中,所有程序均在JDK1.6环境下编译运行正常,除了第13章需要建立ODBC数据源之外,其他程序只要有Java运行环境即可直接运行
💻 JAVA
字号:
import java.applet.*;
import java.awt.*;
public class appletLife extends Applet {
  private int initCount;
  private int startCount;
  private int stopCount;
  private int destroyCount;
  private int paintCount;
  public appletLife () { //构造方法
    //初始化计数器
    initCount = 0;
    startCount = 0;
    stopCount = 0;
    destroyCount = 0;
    paintCount = 0;
  }
  public void init() {
    initCount++; //每次执行init()方法时,initCount加1
  }
  public void start() {
    startCount++; //每次执行start()方法时,startCount加1
  }
  public void stop() {
    stopCount++; //每次执行stop()方法时,stopCount加1
  }
  public void destroy() {
    destroyCount++; //每次执行destroy()方法时,destroyCount加1
  }
  public void paint(Graphics g) {
    paintCount++; //每次执行paint()方法时,paintCount加1
    g.drawString("init()方法执行了" + initCount + "次", 20, 50);
    g.drawString("start()方法执行了" + startCount + "次", 20, 80);
    g.drawString("stop()方法执行了" + stopCount + "次", 20, 110);
    g.drawString("destroy()方法执行了" + destroyCount + "次", 20, 140);
    g.drawString("paint()方法执行了" + paintCount + "次", 20, 170);
  }
}

⌨️ 快捷键说明

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