資源簡介
java實現(xiàn)一個滾動字幕的程序,希望對大家的所幫助。

代碼片段和文件信息
/**
?*?title:????????applet動態(tài)顯示文字
?*?Description:??applet動態(tài)顯示文字編程演示,用于北京師范大學計算機系Java課程教學示范。
?*?Copyright:????Copyright?(c)?2002
?*?Company:??????北京師范大學計算機系
?*?@author?孫一林
?*?@version?1.0
?*/
import?java.awt.*;
import?java.awt.Color;
import?java.awt.Font;
import?java.awt.Graphics;
public?class?RollingMessage?extends?java.applet.applet?implements?Runnable?{
Thread?runThread;
String?s?=?“你好,歡迎瀏覽!“;
int?s_length?=?s.length();
int?x_character?=?0;
Font?wordFont=new?Font(“宋體“??Font.BOLD??50);
public?void?start()?{
if(runThread==null){
runThread?=?new?Thread(this);
runThread.start();
}
}
public?void?stop()?{
if(runThread!=null){
runThread.stop();
runThread=null;
}
}
public?void?run()?{
while(true)?{
if?(x_character++>s_length)
x_character?=?0;
repaint?();
try?{
Thread.sleep(300);
}?catch?(InterruptedException?e)?{}
}
}
public?void?paint?(Graphics?g)?{
g.setFont?(wordFont);
g.setColor?(Color.red);
g.drawString?(s.substring(0x_character)?8?50);
}
???????? ????public?boolean?handleEvent(Event?e)?{ //?事件處理
switch?(e.id)?{
??case?Event.WINDOW_DESTROY:
????System.exit(0);
????return?true;
??default:
????return?false;
}
???? }
public?static?void?main(String?args[])?{ //?Application程序入口
????frame?f?=?new?frame(“動態(tài)顯示文字“); //?創(chuàng)建Application程序框架
????RollingMessage?drawTest?=?new?RollingMessage();
????drawTest.init();
????drawTest.start();
????f.add(“Center“?drawTest);
????f.resize(400?100);
????f.show();
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2005-03-06?17:09??RollingMessage
????.......???????185??2002-09-04?21:03??RollingMessage\ap
????.......????????28??2001-05-17?00:55??RollingMessage\RollingMessage.bat
????.......??????2422??2002-09-04?21:18??RollingMessage\RollingMessage.class
????.......???????644??2002-09-04?21:09??RollingMessage\RollingMessage.html
????.......?????12703??2002-09-04?21:18??RollingMessage\RollingMessage.jar
????.......??????1615??2002-09-04?21:18??RollingMessage\RollingMessage.java
????.......??????1621??2002-09-04?21:10??RollingMessage\RollingMessage.jpr
-----------?---------??----------?-----??----
????????????????19218????????????????????8
- 上一篇:java 倉庫管理系統(tǒng)(完整)
- 下一篇:org.json_0.0.0
評論
共有 條評論