資源簡介
經典java小程序源代碼合集.rar
經典java小程序源代碼合集.rar
經典java小程序源代碼合集.rar

代碼片段和文件信息
/*
?*?Copyright?(c)?2000?David?Flanagan.??All?rights?reserved.
?*?This?code?is?from?the?book?Java?Examples?in?a?Nutshell?2nd?Edition.
?*?It?is?provided?AS-IS?WITHOUT?ANY?WARRANTY?either?expressed?or?implied.
?*?You?may?study?use?and?modify?it?for?any?non-commercial?purpose.
?*?You?may?distribute?it?non-commercially?as?long?as?you?retain?this?notice.
?*?For?a?commercial?use?license?or?to?purchase?the?book?(recommended)
?*?visit?http://www.davidflanagan.com/javaexamples2.
?*/
package?com.davidflanagan.examples.applet;
import?java.applet.*;?????????//?Don‘t?forget?this?import?statement!
import?java.awt.*;????????????//?Or?this?one?for?the?graphics!
import?java.util.Date;????????//?To?obtain?the?current?time
import?java.text.DateFormat;??//?For?displaying?the?time
/**?
?*?This?applet?displays?the?time?and?updates?it?every?second?
?**/
public?class?Clock?extends?applet?implements?Runnable?{
????Label?time;???????????????//?A?component?to?display?the?time?in
????DateFormat?timeFormat;????//?This?object?converts?the?time?to?a?string
????Thread?timer;?????????????//?The?thread?that?updates?the?time
????volatile?boolean?running;?//?A?flag?used?to?stop?the?thread
????/**
?????*?The?init?method?is?called?when?the?browser?first?starts?the?applet.
?????*?It?sets?up?the?Label?component?and?obtains?a?DateFormat?object
?????**/
????public?void?init()?{
time?=?new?Label();
time.setFont(new?Font(“helvetica“?Font.BOLD?12));
time.setAlignment(Label.CENTER);
setLayout(new?BorderLayout());
add(time?BorderLayout.CENTER);
timeFormat?=?DateFormat.getTimeInstance(DateFormat.MEDIUM);
????}
????/**
?????*?This?browser?calls?this?method?to?tell?the?applet?to?start?running.
?????*?Here?we?create?and?start?a?thread?that?will?update?the?time?each
?????*?second.??Note?that?we?take?care?never?to?have?more?than?one?thread
?????**/
????public?void?start()?{
running?=?true;????????????????//?Set?the?flag?
if?(timer?==?null)?{???????????//?If?we?don‘t?already?have?a?thread
????timer?=?new?Thread(this);??//?Then?create?one
????timer.start();?????????????//?And?start?it?running
}
????}
????/**
?????*?This?method?implements?Runnable.??It?is?the?body?of?the?thread.??Once
?????*?a?second?it?updates?the?text?of?the?Label?to?display?the?current?time
?????**/
????public?void?run()?{
while(running)?{?????//?Loop?until?we‘re?stopped
????//?Get?current?time?convert?to?a?String?and?display?in?the?Label
????time.setText(timeFormat.format(new?Date()));??
????//?Now?wait?1000?milliseconds
????try?{?Thread.sleep(1000);?}
????catch?(InterruptedException?e)?{}
}
//?If?the?thread?exits?set?it?to?null?so?we?can?create?a?new?one
//?if?start()?is?called?again.
timer?=?null;
????}
????/**
?????*?The?browser?calls?this?method?to?tell?the?applet?that?it?is?not?visible
?????*?and?should?not?run.??It?sets?a?flag?that?tells?the?run()?method?to?exit
?????**/
????public?void?stop()?{?running?=?false;?}?
????/**
?????*?Returns?information?about?the?applet?for?display?by?th
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1227??2000-06-22?15:50??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件????????118??2000-06-22?15:52??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件???????3130??2000-08-18?12:48??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件????????213??2000-06-22?15:52??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件???????2355??2000-08-18?12:48??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件????????125??2000-06-22?15:54??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件???????5135??2000-08-18?12:48??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件????????125??2000-06-22?15:52??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件????????863??2000-08-18?12:48??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件??????13945??2000-07-13?13:19??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件????????122??2000-06-22?15:52??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件???????2282??2000-08-18?12:48??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件???????1531??2000-07-13?13:31??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件???????6141??2000-08-18?12:48??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\ap
?????文件???????1048??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Echo.java
?????文件???????1757??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\FactComputer.java
?????文件???????1050??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Factorial.java
?????文件????????961??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Factorial2.java
?????文件???????1732??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Factorial3.java
?????文件???????2340??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Factorial4.java
?????文件???????1695??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\FactQuoter.java
?????文件???????1394??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Fibonacci.java
?????文件???????1583??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\FizzBuzz.java
?????文件???????1722??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\FizzBuzz2.java
?????文件????????927??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Hello.java
?????文件???????1198??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Reverse.java
?????文件???????2393??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Rot13Input.java
?????文件???????2738??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\Sieve.java
?????文件???????2052??2000-08-18?12:51??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\basics\SortNumbers.java
?????文件????????971??2000-08-18?12:52??51CTO下載--經典java小程序源代碼合集\經典java小程序源代碼合集\164個JAVA完美程序\beans\Alignment.java
............此處省略294個文件信息
- 上一篇:android 寫的猜紙牌游戲源碼
- 下一篇:java web 博客
評論
共有 條評論