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
-
ConsoleWindow(String)
-
-
ConsoleWindow(String, int)
-
-
actionPerformed(ActionEvent)
-
-
Active()
- returns true if the console window has been activated and is visible
-
Always_Wait_For_Finish()
- unconditionally wait until the console window has been closed
-
BufferedReader()
- get a BufferedReader corresponding to the typein area if this window.
-
dispose()
-
-
getTextArea()
-
-
InputStreamReader()
- get a InputStream corresponding to the typein area if this window.
-
itemStateChanged(ItemEvent)
-
-
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);
}
-
PrintWriter()
-
-
readFile(String)
-
-
Wait_For_Finish()
- wait until the console window has been closed
-
windowActivated(WindowEvent)
-
-
windowClosed(WindowEvent)
-
-
windowClosing(WindowEvent)
-
-
windowDeactivated(WindowEvent)
-
-
windowDeiconified(WindowEvent)
-
-
windowIconified(WindowEvent)
-
-
windowOpened(WindowEvent)
-
-
writeFile(String, String)
-
ConsoleWindow
public ConsoleWindow(String title)
ConsoleWindow
public ConsoleWindow(String title,
int bufferchars)
readFile
public String readFile(String fl)
writeFile
public void writeFile(String fl,
String txt)
dispose
public void dispose()
- Overrides:
- dispose in class Frame
actionPerformed
public void actionPerformed(ActionEvent evt)
itemStateChanged
public void itemStateChanged(ItemEvent evt)
getTextArea
public KeyboardBuffer getTextArea()
PrintWriter
public PrintWriter PrintWriter()
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.
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.
Active
public boolean Active()
- returns true if the console window has been activated and is visible
Wait_For_Finish
public void Wait_For_Finish() throws InterruptedException
- wait until the console window has been closed
Always_Wait_For_Finish
public void Always_Wait_For_Finish()
- unconditionally wait until the console window has been closed
windowActivated
public void windowActivated(WindowEvent ev)
windowDeactivated
public void windowDeactivated(WindowEvent ev)
windowClosed
public void windowClosed(WindowEvent ev)
windowClosing
public void windowClosing(WindowEvent ev)
windowDeiconified
public void windowDeiconified(WindowEvent ev)
windowIconified
public void windowIconified(WindowEvent ev)
windowOpened
public void windowOpened(WindowEvent ev)
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