|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectti.swing.console.InputAdapter
ti.swing.console.ColorInputHandler
An input handler which provides support for color, by use of escaped
sequences of characters. The escape character, and the format of the
escaped character sequences, is not well defined, so the static methods
fgColor(java.awt.Color, java.lang.String)
, bgColor(java.awt.Color, java.lang.String)
, and hyperlink(java.lang.Runnable, java.lang.String)
should be
used, for example:
// to make text with blue background, green foreground: out.println( ColorInputHandler.fgColor( Color.green, ColorInputHandler.bgColor( Color.blue, "Some Text" ) ) ); // to make a hyperlink: out.println( ColorInputHandler.hyperlink( new Runnable() { public void run() { // do something here! } }, "Some Text" ) );Attributes can be combined and nested as needed. Attributes created by
fgColor(java.awt.Color, java.lang.String)
and bgColor(java.awt.Color, java.lang.String)
are constant, and so the resulting
string can be reused, written to disk, read from disk, etc. Attributes
created by hyperlink(java.lang.Runnable, java.lang.String)
are dynamic, and can only be used once for
each time they are created by calling hyperlink(java.lang.Runnable, java.lang.String)
.
Constructor Summary | |
ColorInputHandler(Console console)
Class Constructor. |
Method Summary | |
void |
append(char[] cbuf,
int off,
int len)
Append characters to the end of the character stream. |
static java.lang.String |
bgColor(java.awt.Color c,
java.lang.String str)
Create a string with a background color attribute applied. |
void |
close()
Close method for doing any cleanup. |
static java.lang.String |
fgColor(java.awt.Color c,
java.lang.String str)
Create a string with a foreground color attribute applied. |
static java.lang.String |
hyperlink(java.awt.Color c,
java.lang.Runnable r,
java.lang.String str)
Create a string with a hyperlink. |
static java.lang.String |
hyperlink(java.lang.Runnable r,
java.lang.String str)
Create a string with a hyperlink. |
Methods inherited from class ti.swing.console.InputAdapter |
addRegion, getBufferLock, getData, getOffset, getRegions, lock, removeRegion, unlock, zap |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ColorInputHandler(Console console)
console
- the console we are adding this input handler toMethod Detail |
public static java.lang.String fgColor(java.awt.Color c, java.lang.String str)
c
- the color to applystr
- the string to apply it to
public static java.lang.String bgColor(java.awt.Color c, java.lang.String str)
c
- the color to applystr
- the string to apply it to
public static java.lang.String hyperlink(java.lang.Runnable r, java.lang.String str)
r
- the runnable to invoke when user clicks linkstr
- the string to apply it to
public static java.lang.String hyperlink(java.awt.Color c, java.lang.Runnable r, java.lang.String str)
c
- the color to applyr
- the runnable to invoke when user clicks linkstr
- the string to apply it to
public void append(char[] cbuf, int off, int len)
append
in interface InputHandler
append
in class InputAdapter
cbuf
- the character bufferoff
- the offset into cbuf to first character to appendlen
- the number of characters to appendpublic void close()
InputAdapter
close
in interface InputHandler
close
in class InputAdapter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |