?? falconapplet.java
字號:
package TestApplet;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.Date;
/******************************
顯示當前時間,每秒鐘對顯示作一次刷新
*******************************/
public class FalconApplet extends Applet implements Runnable{
boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();
Thread thread;
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public FalconApplet() {
}
//Initialize the applet
public void init() {
try {
if(thread==null){
thread=new Thread(this,"clock");
thread.start();
}
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
public void run(){
while(Thread.currentThread()==thread){
repaint();
try{
thread.sleep(1000);
}catch(Exception e){
e.printStackTrace();
}
}
}
public void paint(Graphics g){
int h,m,s;
Date now=new Date();
/*h=now.getHours();
m=now.getMinutes();
s=now.getSeconds();
g.drawString(h+":"+m+":"+s,5,10);*/
String r;
r=now.toString();
g.drawString(r,5,10);
}
public void stop(){
thread.stop();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -