?? animation.java
字號:
package animation;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;public class animation extends Applet implements Runnable{ Image Images[]; Thread thread; int Frame; JButton jButton1 = new JButton(); //Construct the applet public animation() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Initialize the applet public void init() { int i; Images = new Image[9]; thread = null; for(i=0;i<Images.length;i++) { Images[i]=getImage(getDocumentBase(),"gif/" + i + ".jpg"); System.out.println("gif/" + i + ".jpg"); } } public void start(){ if (thread == null){ thread = new Thread(this); thread.start(); } } public void stop(){ if (thread != null){ thread.stop(); thread = null; } } public void run(){ while (true){ Frame++; Frame%=(Images.length); repaint(); try{ Thread.sleep(300); } catch (InterruptedException e){} } } public void update(Graphics g) { g.drawImage(Images[Frame],0,0,this); } private void jbInit() throws Exception { jButton1.setBounds(new Rectangle(87, 52, 73, 25)); jButton1.setText("jButton1"); jButton1.addActionListener(new animation_jButton1_actionAdapter(this)); this.setLayout(null); this.setVisible(true); this.add(jButton1, null); } void jButton1_actionPerformed(ActionEvent e) { }}class animation_jButton1_actionAdapter implements java.awt.event.ActionListener { animation adaptee; animation_jButton1_actionAdapter(animation adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -