|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ch.aplu.util.Console
Class to define a console window.
Once the console window is instantiated all output to stdout and stderr is
redirected to this window.
To avoid creating an object the static function init() may be used.
Only one console instance is allowed.
Part of code from Rjhm van den Bergh (rvdb@comweb.nl)
with thanks for the permission to use and distribute
Field Summary |
Fields inherited from interface java.awt.print.Printable |
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
Console()
Construct a Console with default attributes ( see init() ). |
|
Console(Position position,
Size size,
java.awt.Font font)
Construct a Console with attributes. |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent evt)
For internal use only |
static void |
clear()
Erase all text in console window |
static void |
delay(int time)
Delay execution for the given amount of time ( in ms ). |
static void |
end()
Close the console instance. |
java.lang.String |
getAbout()
Return copywrite information |
static java.lang.Double |
getDouble()
Same as readDouble() but returns a Double object. |
javax.swing.JFrame |
getFrame()
Return a reference to the JFrame instance used by the console |
static java.lang.Integer |
getInt()
Same as readInt() but returns an Integer object. |
static char |
getKey()
Return the unicode character associated with last key pressed. |
static int |
getKeyCode()
Return the keycode associated with last key pressed. |
static int |
getKeyCodeWait()
Wait until a key is typed and return the keycode associated with last key pressed. |
static char |
getKeyWait()
Wait until a key is typed and return the unicode character associated with last key pressed. |
static char |
getLastKeyChar()
Return the key character associated with last key pressed. |
static int |
getLastKeyCode()
Return the key code associated with last key pressed. |
static int |
getLastModifiers()
Return the modifiers associated with last key pressed. |
static java.lang.String |
getLastModifiersText()
Return the modifiers text associated with last key pressed. |
static javax.swing.JTextArea |
getTextArea()
Return a reference to the JTextArea of the console window |
java.lang.String |
getVersion()
Return version information |
static Console |
init()
Create a new Console with default attributesand returns a reference to it. |
static Console |
init(java.awt.Font font)
Create a Console with specified font
and returns a reference to it. |
static Console |
init(Position position,
Size size)
Create a Console with specified size and position
and returns a reference to it. |
static Console |
init(Position position,
Size size,
java.awt.Font font)
Create a new Console with specified size, position and font
and returns a reference to it. |
static Console |
init(java.lang.String filename)
Redirect all output to stdout and stderr to a text file with the given filename. |
static boolean |
kbhit()
Return true if a key was hit since the last time the one character buffer was read with getKeyChar() oder getKeyCharWait(). |
void |
keyPressed(java.awt.event.KeyEvent evt)
For internal use only. |
void |
keyReleased(java.awt.event.KeyEvent evt)
For internal use only. |
void |
keyTyped(java.awt.event.KeyEvent evt)
For internal use only. |
static java.lang.String |
pad(java.lang.String num,
int fieldWidth)
Right justify the given number in a field with the given field width (pad the field with leading spaces). |
static java.lang.String |
pad(java.lang.String num,
int fieldWidth,
int decimalWidth)
Pad given number with trailing spaces to optain decimal width and right justify in a field with the given width (pad the the field with leading spaces). |
static Position |
position(int ulx,
int uly)
Return a Position ref with specified upperleft x and y coordinates. |
static Console |
print(boolean b)
Print a boolean value. |
static Console |
print(char c)
Print a character. |
static Console |
print(char[] s)
Print an array of characters. |
static Console |
print(double d)
Print a double-precision floating-point number. |
static Console |
print(float f)
Print a floating-point number. |
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat pf,
int pageIndex)
For internal use only. |
static Console |
print(int i)
Print an integer. |
static Console |
print(long l)
Print a long integer. |
static Console |
print(java.lang.Object obj)
Print an object. |
static Console |
print(java.lang.String s)
Print a string. |
static Console |
println()
Terminate the current line by writing the line separator string. |
static Console |
println(boolean b)
Print a boolean and then terminate the line. |
static Console |
println(char c)
Print a character and then terminate the line. |
static Console |
println(char[] s)
Print an array of characters and then terminate the line. |
static Console |
println(double d)
Print a double and then terminate the line. |
static Console |
println(float f)
Print a float and then terminate the line. |
static Console |
println(int i)
Print an integer and then terminate the line. |
static Console |
println(long l)
Print a long and then terminate the line. |
static Console |
println(java.lang.Object obj)
Print an Object and then terminate the line. |
static Console |
println(java.lang.String s)
Print a String and then terminate the line. |
boolean |
printScreen()
Same as printScreen(scale) with scale = 1 |
boolean |
printScreen(double scale)
Print the current text area to an attached printer with the given magnification scale factor. |
static char |
readChar()
Wait until a key is typed and return the unicode character associated it. |
static double |
readDouble()
Wait until a sequence of numbers with trailing newline is typed. |
static int |
readInt()
Wait until a sequence of numbers with trailing newline is typed. |
static java.lang.String |
readLine()
Wait until a sequence of characters with trailing newline is typed. |
void |
run()
For internal use only. |
static void |
showFonts()
Show all available fonts. |
static Size |
size(int width,
int height)
Return a Size ref with specified width and height. |
static void |
terminate()
Terminate application. |
void |
windowActivated(java.awt.event.WindowEvent e)
For internal use only. |
void |
windowClosed(java.awt.event.WindowEvent evt)
For internal use only. |
void |
windowClosing(java.awt.event.WindowEvent evt)
For internal use only. |
void |
windowDeactivated(java.awt.event.WindowEvent e)
For internal use only. |
void |
windowDeiconified(java.awt.event.WindowEvent e)
For internal use only. |
void |
windowIconified(java.awt.event.WindowEvent e)
For internal use only. |
void |
windowOpened(java.awt.event.WindowEvent e)
For internal use only. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Console(Position position, Size size, java.awt.Font font)
position
- a ref to a Position objectsize
- a ref to a Size objectfont
- a ref to a Font objectPosition
,
Size
,
Font
public Console()
Method Detail |
public static Console init()
Console
with default attributes
public static Console init(Position position, Size size)
Console
with specified size and position
and returns a reference to it.
position
- a ref to a Position objectsize
- a ref to a Size objectPosition
,
Size
public static Console init(java.awt.Font font)
Console
with specified font
and returns a reference to it.
font
- a ref to a Font objectFont
public static Console init(Position position, Size size, java.awt.Font font)
Console
with specified size, position and font
and returns a reference to it.
position
- a ref to a Position objectsize
- a ref to a Size objectfont
- a ref to a Font objectPosition
,
Size
,
Font
public static Console init(java.lang.String filename)
public static void end()
public static void clear()
public static Position position(int ulx, int uly)
new
public static Size size(int width, int height)
public void windowClosed(java.awt.event.WindowEvent evt)
windowClosed
in interface java.awt.event.WindowListener
public void windowClosing(java.awt.event.WindowEvent evt)
windowClosing
in interface java.awt.event.WindowListener
public void windowActivated(java.awt.event.WindowEvent e)
windowActivated
in interface java.awt.event.WindowListener
public void windowDeactivated(java.awt.event.WindowEvent e)
windowDeactivated
in interface java.awt.event.WindowListener
public void windowDeiconified(java.awt.event.WindowEvent e)
windowDeiconified
in interface java.awt.event.WindowListener
public void windowIconified(java.awt.event.WindowEvent e)
windowIconified
in interface java.awt.event.WindowListener
public void windowOpened(java.awt.event.WindowEvent e)
windowOpened
in interface java.awt.event.WindowListener
public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed
in interface java.awt.event.ActionListener
public void run()
run
in interface java.lang.Runnable
public static boolean kbhit()
public static char getKey()
public static int getKeyCode()
public static char getKeyWait()
public static int getKeyCodeWait()
public static char readChar()
public static java.lang.String readLine()
public static int getLastKeyCode()
public static char getLastKeyChar()
public static int getLastModifiers()
public static java.lang.String getLastModifiersText()
public static int readInt()
public static java.lang.Integer getInt()
public static double readDouble()
public static java.lang.Double getDouble()
public static void terminate()
public void keyPressed(java.awt.event.KeyEvent evt)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent evt)
keyReleased
in interface java.awt.event.KeyListener
public void keyTyped(java.awt.event.KeyEvent evt)
keyTyped
in interface java.awt.event.KeyListener
public static void showFonts()
public static void delay(int time)
public static java.lang.String pad(java.lang.String num, int fieldWidth)
public static java.lang.String pad(java.lang.String num, int fieldWidth, int decimalWidth)
public static javax.swing.JTextArea getTextArea()
public static Console print(boolean b)
public static Console print(char c)
public static Console print(char[] s)
public static Console print(double d)
public static Console print(float f)
public static Console print(int i)
public static Console print(long l)
public static Console print(java.lang.Object obj)
public static Console print(java.lang.String s)
public static Console println()
public static Console println(boolean b)
public static Console println(char c)
public static Console println(char[] s)
public static Console println(double d)
public static Console println(float f)
public static Console println(int i)
public static Console println(long l)
public static Console println(java.lang.Object obj)
public static Console println(java.lang.String s)
public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
print
in interface java.awt.print.Printable
public boolean printScreen(double scale)
public boolean printScreen()
public javax.swing.JFrame getFrame()
public java.lang.String getVersion()
public java.lang.String getAbout()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |