public class Trace
extends java.lang.Object
The trace facility can be turned on and off via a menu command. When the trace facility is turned off, the trace window is hidden, and no trace information is recorded. When the trace facility it turned on, the trace window is shown, and trace information will be recorded and displayed in it. The contents of the trace window can also be printed and/or saved to a file.
As well as printing information into the trace window, the program can also invoke the Trace.pause method that will temporarily pause the program until the user is ready to proceed.
The methods of the Trace class are all static, so that the Trace.print and Trace.println methods can be called from any point in the program.
The program must have created an UI window in order to use the trace facility, but there is no need to explicitly create a trace window or initialise the trace facility from inside the program. For more sophisticated debugging, it is possible to turn the trace facility on or off from inside the program (and also to determine whether it is on, and to print or save the contents of the trace window), but this is not necessary for simple use.
Modifier and Type | Method and Description |
---|---|
static void |
setVisible(boolean v)
Make the trace window visible.
|
static void |
hide()
Hide the trace window.
|
static boolean |
isVisible()
Return true if and only if the trace window is currently visible.
|
static void |
pause() pause(String s)
If the trace window is visible, display a dialog box allowing the user to pause the program until they are ready to
proceed. The dialog box displays the argument, if provided.
|
static void |
print(boolean b) print(char c) print(double d) print(int i) print(String s) print(Object o) println() println(boolean b) println(char c) println(double d) println(int i) println(String s) println(Object o)
If the trace window is currently showing, print a value (any
type) into the trace window. The println version also starts
a new line. Does nothing if trace window is hidden.
|
static void |
printf(String format,
Object... args)
If the trace window is currently showing, prints a formatted
string into the Trace window, just like printf for UI or PrintStream.
|