import java.awt.*; import Ticket; public class TicketReader extends java.applet.Applet implements Runnable { Thread runner; String ticketFace = "Waiting to get ticket\n"; 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) { try { Thread.sleep(1000); } catch (InterruptedException e) {} if (Ticket.getTicket() != 0) { ticketFace = "The ticket is now " + Ticket.getTicket(); } repaint(); } } public void paint(Graphics g) { Font font = new Font("Times Roman", Font.PLAIN, 20); FontMetrics fm = getFontMetrics(font); g.setFont(font); int x = (this.size().width - fm.stringWidth(ticketFace)) / 2; int y = (this.size().height - fm.getHeight()) / 2; g.drawString(ticketFace, x, y); } }