91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 183KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-09
  • 語言: Java
  • 標簽: Java??Applet??動態顯示??

資源簡介

簡單的一個Java Applet的動態顯示圖片的小程序。將資源內的圖片放置到E盤根目錄下。如果想換圖片,記得修改width和heigh的初始值,值為圖片的寬和高。如果你對動畫有興趣,可以試著稍微修改一下本程序(程序里有相關的提示),添加幾張連續的圖片,就可以實現了。我的另一個同名的資源,是我上傳錯的,功能都有,但差了點代碼。建議下載這個。

資源截圖

代碼片段和文件信息

package?com.yourcompany.struts.action;

import?java.applet.applet;
import?java.awt.Button;
import?java.awt.Color;
import?java.awt.Graphics;
import?java.awt.Image;
import?java.awt.Label;
import?java.awt.TextField;
import?java.awt.Toolkit;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?java.net.MalformedURLException;
import?java.net.URL;

import?javax.swing.JOptionPane;

public?class?MyActLit?extends?applet?implements?ActionListener?{
Toolkit?tool?=?getToolkit();
Image?image;
Button?bu1;
Button?bu2;
Button?bu3;
Button?bu4;
TextField?text;
TextField?text1;
int?x1?=?0;
int?y1?=?0;
int?x2?=?600;
int?width?=?400;
int?heigh?=?20643;
int?speed?=?1;
int?speed1?=?1000;
int?x3?=?1050;
int?y3?=?10;
boolean?sd?=?false;
Thread?th;
//String?tupian[]?=?new?String[5];?初始5張連續的圖片的絕對路徑

public?void?init()?{
image?=?tool.getImage(“E://1.jpg“);
bu1?=?new?Button(“向下“);
bu2?=?new?Button(“向上“);
bu3?=?new?Button(“確認自動滾動速度“);
bu4?=?new?Button(“確認手動滾動速度“);
text?=?new?TextField(“1“);
text1?=?new?TextField(“1000“);
this.add(bu1);
this.add(bu2);
this.add(text);
this.add(bu3);
this.add(text1);
this.add(bu4);
bu1.addActionListener(this);
bu2.addActionListener(this);
bu3.addActionListener(this);
bu4.addActionListener(this);
th?=?new?dd();
th.start();
}

@Override
public?void?paint(Graphics?g)?{
//?TODO?Auto-generated?method?stub
g.setColor(Color.black);
g.drawImage(image?10?10?450?910?x1?y1?x2?y1?+?900?this);
g.drawImage(image?500?10?550?910?0?0?width?heigh?this);
g.setColor(Color.red);
g.drawRect(495?y3?59?40);
}

/*
?*?可以在下面修改,制作動畫
?*?
?*?
?*?public?void?paint(Graphics?g)?{?//?TODO?Auto-generated?method?stub
?*?畫出圖片真實的大小,自己設置大小吧
?*?g.drawImage(image?10?10?450?910?0?0?x2?y1?+?900?this);?}
?*/

public?boolean?validatelenth()?{
boolean?s?=?true;
if?(y1?+?1000?>?heigh?||?y1? s?=?false;
}
return?s;
}

public?void?validateSpeed()?{

}

public?void?actionPerformed(ActionEvent?ac)?{
//?TODO?Auto-generated?method?stub
Button?bnt?=?(Button)?ac.getSource();
try?{
if?(bnt?==?bu1)?{
y1?+=?speed1;

}?else?if?(bnt?==?bu2)?{
y1?-=?speed1;
}?else?if?(bnt?==?bu3)?{
speed?=?Integer.valueOf(text.getText());
}?else?if?(bnt?==?bu4)?{
speed1?=?Integer.valueOf(text1.getText());
}
}?catch?(Exception?ex)?{
JOptionPane.showMessageDialog(null?“輸入的為非數字,確認后再點“?“錯誤“
JOptionPane.ERROR_MESSAGE);
}
if?(!validatelenth())
return;
y3?=?(900?*?(y1)?/?(heigh?-?900));
repaint();
}

class?dd?extends?Thread?{

//?TODO?Auto-generated?method?stub
public?void?run()?{
while?(1?>?0)?{
if?(sd)?{
y1?-=?speed;
}?else?{
y1?+=?speed;
}
y3?=?(900?*?(y1)?/?(heigh?-?900));
if?(!validatelenth())?{
if?(!sd)?{
sd?=?true;
}?else?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????3698??2010-06-29?10:03??MyActLit.java

?????文件?????248382??2010-06-28?19:34??1.jpg

-----------?---------??----------?-----??----

???????????????252080????????????????????2


評論

共有 條評論