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

📄 applet1.java~7~

📁 可以看动画的多线程applet
💻 JAVA~7~
字号:
package exp3;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.awt.Panel;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class Applet1 extends Applet {
  Image imgSeq[];
  int numImg=10;
  String fname="T";
  int i=0;
  Button b1,b2;

  private boolean isStandalone = false;
  //Get a parameter value
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
      (getParameter(key) != null ? getParameter(key) : def);
  }

  //Construct the applet
  public Applet1() {
    b1.setActionCommand("haha");


  }
  //Initialize the applet
  public void init() {

    imgSeq=new Image[numImg];
    for (int j=1;j<=numImg;j++)
      imgSeq[j-1]=getImage(getCodeBase(),fname+j+".gif");
    Panel p1=new Panel();
    p1.setBackground(Color.yellow);
    p1.add(b1=new Button("button in panel1"));
    p1.add(new TextField("in panel1"));
    add(p1);



    Panel p2=new Panel();
    p2.setBackground(Color.green);
    p2.add(b2=new Button("button in panel2"));
    p2.add(new TextField("in panel2"));
    add(p2);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Component initialization
  public void paint(Graphics e){
    if (b1.getActionCommand()=="haha"){
    e.drawImage(imgSeq[i],50,50,this);
    i=i+1;
    if(i==10)
      i=0;
    for(int j=0;j<2000000;j++)
      j=j;
      repaint();
    }

  }
  private void jbInit() throws Exception {
    this.setBackground(SystemColor.control);
  }
  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  }
  //Get parameter info
  public String[][] getParameterInfo() {
    return null;
  }

}

⌨️ 快捷键说明

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