All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class dlib.ConsoleWindow

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Frame
                                   |
                                   +----dlib.ConsoleWindow

public class ConsoleWindow
extends Frame
implements WindowListener, ActionListener, ItemListener
This class implements a simple console window, conceptually a replacement for reading/writing to System.out and System.in; The advantage of this over System.xx is that it works with JDB, the contents of the window can be saved, and *major feature* the typein and typeout can be edited. The intended use is as a programmer's shell for messages and simple command processing while developing programs. See the "main" method in this file for an example how to use it.

See Also:
Deferred_PrintWriter

Constructor Index

 o ConsoleWindow(String)
 o ConsoleWindow(String, int)

Method Index

 o actionPerformed(ActionEvent)
 o Active()
returns true if the console window has been activated and is visible
 o Always_Wait_For_Finish()
unconditionally wait until the console window has been closed
 o BufferedReader()
get a BufferedReader corresponding to the typein area if this window.
 o dispose()
 o getTextArea()
 o InputStreamReader()
get a InputStream corresponding to the typein area if this window.
 o itemStateChanged(ItemEvent)
 o main(String[])
 public static void main (String args[])
 { String name = args.length >= 1 ? args[0] : "Console";
   ConsoleWindow console = new ConsoleWindow(name);
   PrintStream out = console.PrintStream();
   DataInputStream in = console.DataInputStream();
   out.println("ready");
  while (console.Active())
   {
    out.print("> ");
    try 
    {String str = in.readLine();
 		out.println("Typed line: " + str);
   }
   catch (IOException err) {};
   };
   System.exit(0);
  }
 
 o PrintWriter()
 o readFile(String)
 o Wait_For_Finish()
wait until the console window has been closed
 o windowActivated(WindowEvent)
 o windowClosed(WindowEvent)
 o windowClosing(WindowEvent)
 o windowDeactivated(WindowEvent)
 o windowDeiconified(WindowEvent)
 o windowIconified(WindowEvent)
 o windowOpened(WindowEvent)
 o writeFile(String, String)

Constructors

 o ConsoleWindow
 public ConsoleWindow(String title)
 o ConsoleWindow
 public ConsoleWindow(String title,
                      int bufferchars)

Methods

 o readFile
 public String readFile(String fl)
 o writeFile
 public void writeFile(String fl,
                       String txt)
 o dispose
 public void dispose()
Overrides:
dispose in class Frame
 o actionPerformed
 public void actionPerformed(ActionEvent evt)
 o itemStateChanged
 public void itemStateChanged(ItemEvent evt)
 o getTextArea
 public KeyboardBuffer getTextArea()
 o PrintWriter
 public PrintWriter PrintWriter()
 o InputStreamReader
 public InputStreamReader InputStreamReader()
get a InputStream corresponding to the typein area if this window. Note that the input from the InputStream will be line buffered, so no input is available from incomplete lines.

 o BufferedReader
 public BufferedReader BufferedReader()
get a BufferedReader corresponding to the typein area if this window. Note that the input from the BufferedReader will be line buffered, so no input is available from incomplete lines.

 o Active
 public boolean Active()
returns true if the console window has been activated and is visible

 o Wait_For_Finish
 public void Wait_For_Finish() throws InterruptedException
wait until the console window has been closed

 o Always_Wait_For_Finish
 public void Always_Wait_For_Finish()
unconditionally wait until the console window has been closed

 o windowActivated
 public void windowActivated(WindowEvent ev)
 o windowDeactivated
 public void windowDeactivated(WindowEvent ev)
 o windowClosed
 public void windowClosed(WindowEvent ev)
 o windowClosing
 public void windowClosing(WindowEvent ev)
 o windowDeiconified
 public void windowDeiconified(WindowEvent ev)
 o windowIconified
 public void windowIconified(WindowEvent ev)
 o windowOpened
 public void windowOpened(WindowEvent ev)
 o main
 public static void main(String args[])
 public static void main (String args[])
 { String name = args.length >= 1 ? args[0] : "Console";
   ConsoleWindow console = new ConsoleWindow(name);
   PrintStream out = console.PrintStream();
   DataInputStream in = console.DataInputStream();
   out.println("ready");
  while (console.Active())
   {
    out.print("> ");
    try 
    {String str = in.readLine();
 		out.println("Typed line: " + str);
   }
   catch (IOException err) {};
   };
   System.exit(0);
  }
 


All Packages  Class Hierarchy  This Package  Previous  Next  Index