clock.java~13~

来自「Jbuilder100个例子 都是经典例子 对大家学习Jbuilder非常有帮助」· JAVA~13~ 代码 · 共 64 行

JAVA~13~
64
字号
import java.awt.*;import java.awt.event.*;import java.applet.*;import  java.util.Date;public class clock extends java.applet.Applet implements Runnable{   Font myfont=new Font("TimesRoman",Font.BOLD,18);   Color mycolor=new Color(255,0,0);   Date mydate;   Thread runner;  boolean isStandalone = false;  /**Get a parameter value*/  public String getParameter(String key, String def) {    return isStandalone ? System.getProperty(key, def) :      (getParameter(key) != null ? getParameter(key) : def);  }  public void start()  {if(runner==null){      runner=new Thread(this);      runner.start();      }  }  public void stop()  { if(runner!=null){       runner.stop();       runner=null;   }}   public void run(){   while(true){   mydate=new Date();   repaint();   try{Thread.sleep(1000); }   catch(InterruptedException e){}   }}   public void paint(Graphics g)   {g.setFont(myfont);   g.setColor(mycolor);   g.drawString(mydate.toString(),10,50);   }  /**Construct the applet*/  public clock() {  }  /**Initialize the applet*/  public void init() {    try {      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;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?