?? watch.java
字號:
/* X11Like.java Copyright F. P. Marin ( April 07 13:12:53 1997 ) E-mail: felix@bloch.ciens.ucv.ve Permission to use, copy, modify and distribute this software and its documentation for NON-COMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies. F. P. Marin makes no representations or warranties about the suitability of the software, either express or implied, including but no limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. F. P. Marin shall not be liable for any damage suffered by license as a result of using, modifying or distributing this software or its derivatives. Html code is <applet archive="X11Like.jar" code="X11Like.class" height=85 width=325> </applet>*/import java.awt.*;import java.util.Date;public class X11Like extends java.applet.Applet implements Runnable{ Font f=new Font("TimesRoman",Font.BOLD,14); FontMetrics fm=getFontMetrics(f); int x,y; String s; Thread watch=null; public void init() { setLayout(new BorderLayout()); add("North",new Button("")); add("South",new Button("")); add("East",new Button("")); add("West",new Button("")); y=(int)(0.5*(size().height + fm.getAscent() + 1)); } public void start() { if ( watch==null ) { watch=new Thread(this); watch.start(); } } public void run() { do { s=new Date().toLocaleString(); x=(size().width - fm.stringWidth(s))/2; repaint(); try { Thread.sleep(1000); } catch ( InterruptedException ie ) {} } while ( true ); } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { g.setColor(Color.black); g.fillRect(0,0,size().width,size().height); g.setColor(Color.green.brighter()); g.setFont(f); g.drawString(s,x,y); } public void stop() { if ( watch!=null ) { watch.stop(); watch=null; } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -