public class Console
extends java.lang.Object
implements java.lang.Runnable, java.awt.print.Printable
Constructor and Description |
---|
Console()
Construct a Console with default attributes ( see init() ).
|
Console(Position position,
Size size,
java.awt.Font font)
Construct a Console with attributes.
|
Modifier and Type | Method and Description |
---|---|
static void |
addExitListener(ExitListener exitListener)
Register an ExitListener to get a notification when the close button is clicked.
|
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()
Hide the console window and releases resources.
|
static java.lang.Double |
getDouble()
Same as readDouble() but returns a Double object.
|
static 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 and flush the
one-charactor buffer.
|
static int |
getKeyCode()
Return the keycode associated with last key pressed and
flush the one-character buffer.
|
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 |
getLastKey()
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
|
static void |
hide()
Hide the console window.
|
static Console |
init()
If no console was created before, create a new Console instance
with default attributes and returns a reference to it; otherwise
return the existing Console reference and show the exiting console
window if it was hidden (content is erased).
|
static Console |
init(java.awt.Font font)
If no console was created before, create a new Console instance
with given font and returns a reference to it; otherwise
return the existing Console reference and use the given font.
|
static Console |
init(Position position,
Size size)
If no console was created before, create a new Console instance
with given position and size and returns a reference to it; otherwise
return the existing Console reference and show the exiting console window
with new position and size.
|
static Console |
init(Position position,
Size size,
java.awt.Font font)
If no console was created before, create a new Console instance
with given position, size, font and returns a reference to it; otherwise
return the existing Console reference and use the position, size and font.
|
static Console |
init(java.lang.String filename)
Redirect all output to stdout and stderr to a text file
with the given filename.
|
static Console |
initw()
Same as init() but enable autowrapping.
|
static Console |
initw(java.awt.Font font)
Same as init(Font font) but enable autowrapping.
|
static Console |
initw(Position position,
Size size)
Same as init(Position position, Size size), but enable autowrapping.
|
static Console |
initw(Position position,
Size size,
java.awt.Font font)
Same as init(Position position, Size size, Font font) but enable autowrapping.
|
boolean |
isDisposed()
Return true, if the Console windows was disposed or released.
|
static boolean |
kbhit()
Return true if a key was hit since the last time the one-character buffer
was read with getKey() oder getKeyWait().
|
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 reference 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 |
printf(java.util.Locale l,
java.lang.String format,
java.lang.Object... args)
Print a formatted string using the specified format string and varargs
and applying given locale during formatting.
|
static Console |
printf(java.lang.String format,
java.lang.Object... args)
Print a formatted string using the specified format string and varargs.
|
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 |
setAutowrap(boolean enable)
Enable/disable autowrapping.
|
static void |
setTitle(java.lang.String title)
Set another title in the console's title bar.
|
static void |
show()
Show the console window.
|
static void |
showFonts()
Show all available fonts.
|
static void |
showHorizontalScrollBar(boolean b)
Insert/remove a horizonal scroll bar.
|
static void |
showVerticalScrollBar(boolean b)
Insert/remove a vertical scroll bar.
|
static Size |
size(int width,
int height)
Return a Size reference with specified width and height.
|
static void |
terminate()
Terminate application.
|
public Console(Position position, Size size, java.awt.Font font)
public Console()
public static Console init()
public static Console initw()
public static Console init(Position position, Size size)
public static Console initw(Position position, Size size)
public static Console init(java.awt.Font font)
font
- a reference to a Font objectFont
public static Console initw(java.awt.Font font)
public static Console init(Position position, Size size, java.awt.Font font)
public static Console initw(Position position, Size size, java.awt.Font 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 static void addExitListener(ExitListener exitListener)
public void run()
run
in interface java.lang.Runnable
public static void show()
public static void hide()
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 char getLastKey()
public static int getLastKeyCode()
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 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 static Console printf(java.lang.String format, java.lang.Object... args)
public static Console printf(java.util.Locale l, java.lang.String format, java.lang.Object... args)
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 static javax.swing.JFrame getFrame()
public static void showVerticalScrollBar(boolean b)
public static void showHorizontalScrollBar(boolean b)
public static void setTitle(java.lang.String title)
public static void setAutowrap(boolean enable)
public boolean isDisposed()