/* * AppHolder.java - ApHolder holds an application on a web page. * * Copyright (c) 1996 Chuck McManis, All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * and its documentation for NON-COMMERCIAL purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. * * CHUCK MCMANIS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. CHUCK MCMANIS * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT * OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ import java.applet.Applet; import util.comm.DataChannelInputStream; import util.comm.DataChannelOutputStream; import java.io.PrintStream; import java.io.InputStream; import java.io.IOException; import java.awt.Graphics; import java.awt.Color; import java.awt.Event; import java.awt.FontMetrics; import java.io.DataInputStream; public class AppHolder extends Applet implements Runnable { PrintStream x; DataChannelOutputStream dco; DataChannelInputStream dci; String apName = "Sample Application"; int rx, ry, rx1, ry1; public void init() { dco = new DataChannelOutputStream("console.screen"); dci = new DataChannelInputStream("console.keyboard"); } public void paint(Graphics g) { FontMetrics fm = g.getFontMetrics(); int z; int h = fm.getHeight(); g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); g.setColor(Color.black); g.drawRoundRect(0, 0, getSize().width, getSize().height, 5, 5); z = fm.stringWidth("RESET"); rx = getSize().width - (z+16); ry = (getSize().height - (h + 8))/2; g.setColor(Color.red); g.drawRoundRect(rx, ry, z+8, h+8, 5, 5); rx1 = rx + z+8; ry1 = ry + h+8; g.drawString("RESET", rx+4, ry+4+fm.getMaxAscent()); g.setColor(Color.black); g.drawString(apName, 4 , ((getSize().height - h)/2)+fm.getMaxAscent()); } Thread spooger = null; public boolean mouseUp(Event e, int x, int y) { if ((x > rx) && (x < rx1) && (y > ry) && (y < ry1)) { if (spooger.isAlive()) { spooger.stop(); } spooger = new Thread(this); spooger.start(); return true; } return false; } public void start() { spooger = new Thread(this); spooger.start(); } public void stop() { spooger = null; } public void destroy() { spooger = null; } public void run() { int count = 0; byte localbuf[] = new byte[128]; SampleApp.run_app(new DataInputStream(dci),new PrintStream(dco, true)); } }