/* 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 */ 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; } } }