public class GConsole
extends java.lang.Object
implements java.lang.Runnable, java.awt.print.Printable
Modifier and Type | Class and Description |
---|---|
static class |
GConsole.ClosingMode |
Constructor and Description |
---|
GConsole()
Construct a Console with default attributes.
|
GConsole(java.awt.Font font)
Construct a Console with given font and default position and size.
|
GConsole(Position position,
Size size)
Construct a Console with given position, size and default font.
|
GConsole(Position position,
Size size,
java.awt.Font font)
Construct a Console with given attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
addExitListener(ExitListener exitListener)
Register an ExitListener to get a notification when the close button is clicked.
|
void |
checkDisposed() |
void |
clear()
Erase all text in console window
|
void |
delay(int time)
Delay execution for the given amount of time ( in ms ).
|
void |
deleteLastChar()
Deletes the last character and adjusts the cursor.
|
void |
dispose()
Disposes the console frame.
|
void |
end()
Hide the console window and releases resources.
|
GConsole.ClosingMode |
getClosingMode(ch.aplu.util.MyProperties props) |
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
|
java.lang.Integer |
getInt()
Same as readInt() but returns an Integer object.
|
char |
getKey()
Return the unicode character associated with last key pressed and flush the
one-charactor buffer.
|
char |
getKey(boolean keep)
Return the unicode character associated with last key pressed
and keep the one-charactor buffer if keep = true.
|
int |
getKeyCode()
Return the keycode associated with last key pressed and
flush the one-character buffer.
|
int |
getKeyCodeWait()
Wait until a key is typed and
return the keycode associated with last key pressed.
|
int |
getKeyInt()
Return the 8-bit ASCII code associated with last key pressed and flush the
one-charactor buffer.
|
char |
getKeyWait()
Wait until a key is typed and
return the unicode character associated with last key pressed.
|
int |
getKeyWaitInt()
Return the 8-bit ASCII code associated with last key pressed and flush the
one-charactor buffer.
|
char |
getLastKey()
Return the key character associated with last key pressed.
|
int |
getLastKeyCode()
Return the key code associated with last key pressed.
|
java.lang.String |
getLastLine()
Returns the last line of the text area.
|
int |
getLastModifiers()
Return the modifiers associated with last key pressed.
|
java.lang.String |
getLastModifiersText()
Return the modifiers text associated with last key pressed.
|
javax.swing.JTextArea |
getTextArea()
Return a reference to the JTextArea of the console window
|
void |
hide()
Hide the console window.
|
boolean |
isDisposed()
Return true, if the Console windows was disposed or released.
|
boolean |
kbhit()
Return true if a key was hit since the last time the one-character buffer
was read with getKey() oder getKeyWait().
|
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).
|
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).
|
Position |
position(int ulx,
int uly)
Return a Position reference with specified upperleft x and y coordinates.
|
void |
print(boolean b)
Print a boolean value.
|
void |
print(char c)
Print a character.
|
void |
print(char[] s)
Print an array of characters.
|
void |
print(double d)
Print a double-precision floating-point number.
|
void |
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.
|
void |
print(int i)
Print an integer.
|
void |
print(long l)
Print a long integer.
|
void |
print(java.lang.Object obj)
Print an object.
|
void |
print(java.lang.String s)
Print a string.
|
void |
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.
|
void |
printf(java.lang.String format,
java.lang.Object... args)
Print a formatted string using the specified format string and varargs.
|
void |
println()
Terminate the current line by writing the line separator string.
|
void |
println(boolean b)
Print a boolean and then terminate the line.
|
void |
println(char c)
Print a character and then terminate the line.
|
void |
println(char[] s)
Print an array of characters and then terminate the line.
|
void |
println(double d)
Print a double and then terminate the line.
|
void |
println(float f)
Print a float and then terminate the line.
|
void |
println(int i)
Print an integer and then terminate the line.
|
void |
println(long l)
Print a long and then terminate the line.
|
void |
println(java.lang.Object obj)
Print an Object and then terminate the line.
|
void |
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.
|
char |
readChar()
Wait until a key is typed and
return the unicode character associated it.
|
double |
readDouble()
Wait until a sequence of numbers with trailing newline is typed.
|
int |
readInt()
Wait until a sequence of numbers with trailing newline is typed.
|
java.lang.String |
readLine()
Wait until a sequence of characters with trailing newline is typed.
|
void |
run()
For internal use only.
|
void |
setAutowrap(boolean enable)
Enable/disable autowrapping.
|
void |
setCaretPosition(int pos) |
void |
setClosingMode(GConsole.ClosingMode mode)
Determines what happens when the title bar close button is hit.
|
void |
setTitle(java.lang.String title)
Set another title in the console's title bar.
|
void |
show()
Show the console window.
|
void |
showFonts()
Show all available fonts.
|
void |
showHorizontalScrollBar(boolean b)
Insert/remove a horizonal scroll bar.
|
void |
showVerticalScrollBar(boolean b)
Insert/remove a vertical scroll bar.
|
Size |
size(int width,
int height)
Return a Size reference with specified width and height.
|
void |
terminate()
Terminate application.
|
public GConsole(Position position, Size size, java.awt.Font font)
position
- a reference to a Position objectsize
- a reference to a Size objectfont
- a reference to a Font objectpublic GConsole()
public GConsole(Position position, Size size)
position
- a reference to a Position objectsize
- a reference to a Size objectpublic GConsole(java.awt.Font font)
font
- a reference to a Font objectpublic void end()
public void clear()
public Position position(int ulx, int uly)
new
public Size size(int width, int height)
public void addExitListener(ExitListener exitListener)
public void run()
run
in interface java.lang.Runnable
public void setCaretPosition(int pos)
public void show()
public void hide()
public boolean kbhit()
public char getKey()
public char getKey(boolean keep)
public int getKeyInt()
public int getKeyWaitInt()
public int getKeyCode()
public char getKeyWait()
public int getKeyCodeWait()
public char readChar()
public java.lang.String readLine()
public char getLastKey()
public int getLastKeyCode()
public int getLastModifiers()
public java.lang.String getLastModifiersText()
public int readInt()
public java.lang.Integer getInt()
public double readDouble()
public java.lang.Double getDouble()
public void terminate()
public void showFonts()
public void delay(int time)
public java.lang.String pad(java.lang.String num, int fieldWidth)
public java.lang.String pad(java.lang.String num, int fieldWidth, int decimalWidth)
public javax.swing.JTextArea getTextArea()
public void print(boolean b)
public void print(char c)
public void print(char[] s)
public void print(double d)
public void print(float f)
public void print(int i)
public void print(long l)
public void print(java.lang.Object obj)
public void print(java.lang.String s)
public void println()
public void println(boolean b)
public void println(char c)
public void println(char[] s)
public void println(double d)
public void println(float f)
public void println(int i)
public void println(long l)
public void println(java.lang.Object obj)
public void println(java.lang.String s)
public void printf(java.lang.String format, java.lang.Object... args)
public void 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 javax.swing.JFrame getFrame()
public void showVerticalScrollBar(boolean b)
public void showHorizontalScrollBar(boolean b)
public void setTitle(java.lang.String title)
public void setAutowrap(boolean enable)
public GConsole.ClosingMode getClosingMode(ch.aplu.util.MyProperties props)
public void checkDisposed()
public boolean isDisposed()
public void setClosingMode(GConsole.ClosingMode mode)
public void deleteLastChar()
public java.lang.String getLastLine()
public void dispose()