ͼƬΪʲô²»ÏÔʾ£¿Ð»Ð»~~
package javaDaZuoYe;import java.applet.*;
import java.awt.*;
import java.awt.event.*;
//ͼƬΪʲô²»ÏÔʾ£¿Ð»Ð»~~
public class PlayPic extends Applet implements ActionListener {
//¶¨ÒåչʾͼƬµÄÊýÁ¿Îª³£Êý10
final int num=10;
//¶¨Ò嵱ǰͼƬµÄÐòºÅ
int cnt;
Button button1,button2;
Label label;
//¶¨ÒåÒ»¸öͼƬÊý×é
Image[] pic;
public void init(){
//³õʼ»¯
cnt=-1;
//½«¶ÔÏópicʵÀý»¯
pic=new Image[num];
for(int i=0;i<num;i++) {
pic[i]=getImage(getCodeBase(),"atp"+i+".gif");
}
//ÉèÖÃΪ¿Õ²¼¾Ö
setLayout(null);
button1=new Button("ÏòÇ°");
button2=new Button("Ïòºó");
label=new Label("ÎÒϲ»¶Í¼Æ¬",Label.CENTER);
//Ìí¼Ó×é¼þ
add(button1);
add(button2);
add(label);
//É趨×é¼þµÄλÖúʹóС
label.setBounds(0,0,180,30);
button1.setBounds(0,240,90,30);
button2.setBounds(90,240,90,30);
//Ìí¼Ó°´Å¥µã»÷ʼþµÄ¼àÊÓÆ÷
button1.addActionListener(this);
button2.addActionListener(this);
}
public void start() {
}
public void stop() {
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==button1){
if(cnt>=9) {
//µ±Í¼Æ¬ÐòºÅ×î´óʱ£¬"ÏòÇ°"°´Å¥²»¿Éµã»÷
button1.setEnabled(false);
} else {
//°´Å¥»Ö¸´Îª¿ÉÒÔµã»÷
button1.setEnabled(true);
button2.setEnabled(true);
//ͼƬÐòºÅµÝÔö
cnt++;
//ÖػСӦÓóÌÐò
repaint();
}
} else if(e.getSource()==button2){
if(cnt<=0) {
//µ±Í¼Æ¬ÐòºÅ×îСʱ£¬"Ïòºó"°´Å¥²»¿Éµã»÷
button2.setEnabled(false);
} else {
//°´Å¥»Ö¸´Îª¿ÉÒÔµã»÷
button1.setEnabled(true);
button2.setEnabled(true);
//ͼƬÐòºÅµÝ¼õ
cnt--;
//ÖػСӦÓóÌÐò
repaint();
}
}
}
public void paint(Graphics g) {
if((pic[cnt])!=null) {
//½«Í¼Æ¬»ÔÚСӦÓóÌÐòÉÏ
g.drawImage(pic[cnt],10,100,pic[cnt].getWidth(this),pic[cnt].getHeight(this),this);
} else {
//½«»±ÊÉèΪºìÉ«
g.setColor(Color.red);
g.drawString("Ò»»á¶ù½«Ïò´ó¼Òչʾ×îÐÂͼƬ!!!!",10,100);
}
}
}
¸½¼þÖÐÊÇ×ܵÄÎļþ¡£
----------------½â¾ö·½°¸--------------------------------------------------------
Applet????»¹Ã»ÓÐÑо¿
----------------½â¾ö·½°¸--------------------------------------------------------
ÎÒÔËÐпÉÒÔÏÔʾͼƬàÞ!
----------------½â¾ö·½°¸--------------------------------------------------------
??
ÓÃswing Ò²¿É°ÉIamageIcon
Applet ÎÒÈ¥¿´¿´APIÎĵµ ÔÙÀ´ !
ÉÁ£¡
----------------½â¾ö·½°¸--------------------------------------------------------
ÓÐʱºò¼´Ê¹ÄãµÄ³ÌÐòÊǶԵģ¬ÔÚä¯ÀÀÆ÷ÖÐÒ²²»ÄÜÕý³£ÏÔʾµÄ¡£
Õâ¸úä¯ÀÀÆ÷ÓйØϵµÄ¡£
----------------½â¾ö·½°¸--------------------------------------------------------
»Ø¸´ 1# µÄÌû×Ó
ÎÒÔËÐÐʱҲûÓÐÎÊÌ⣬ºÇºÇ ----------------½â¾ö·½°¸--------------------------------------------------------