package com.abl.gui; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.*; //Console: /** like a graphical System.out @version 11/29/2000 @author I made this. -- prie, 8/15/98 */ final public class Console { /*private*/ static Frame console = null; /* 1.1 workarounds */ /*private*/ static TextArea textArea = null; private static String newline = null; /*private*/ static boolean standAlone = true; public static void setAppContext(boolean inAnApplet) { standAlone = !inAnApplet; } public static void println(String text) { if (console == null) createConsole(); if (textArea == null) { //create textArea and make visible textArea = new TextArea(20, 70); console.add("Center", textArea); console.pack(); console.setVisible(true); newline = System.getProperty("line.separator"); //(grab while here) } textArea.append(text + newline); //println } public static void stop(String message) { //after Jack Harich Exception ex = new Exception(message); ex.printStackTrace(); console.setVisible(false); //cleanup and exit console.dispose(); if (standAlone) System.exit(911); console = null; //force dispose textArea = null; } public static Frame getFrame() { //Dialogs can hang their hats here if (console == null) createConsole(); return console; } private static void createConsole() { console = new Frame("com.abl.gui.Console"); console.addWindowListener( new WindowAdapter() { //anonymous class to handle: public void windowClosing(WindowEvent e) { console.setVisible(false); //cleanup and exit console.dispose(); if (standAlone) System.exit(0); console = null; //force dispose textArea = null; } }); } }