edu.mit.util
Class Debug
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--java.awt.Window
|
+--java.awt.Frame
|
+--javax.swing.JFrame
|
+--edu.mit.util.Debug
- All Implemented Interfaces:
- Accessible, ImageObserver, MenuContainer, RootPaneContainer, Serializable, WindowConstants
- public class Debug
- extends JFrame
This class provides a mechanism for displaying debug output in
separate panels of a tabbed window. The target page of the panel
is specified by a string.
For example:
Debug.println( "speed info", speedinfoObj )
In addition buttons can be added to the debug window with the
addButton(String title, JButton button) or
addButton(String title, String buttonName, ActionListener listener)
methods. This is useful for having simple on demand
output such as printing the value of a variable or performing
actions that are not performed outside of a debuging context.
The frame will be opened the first time that it is accessed.
See the main function for a demonstration.
- See Also:
- Serialized Form
| Fields inherited from class java.awt.Frame |
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
| Methods inherited from class javax.swing.JFrame |
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update |
| Methods inherited from class java.awt.Frame |
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle |
| Methods inherited from class java.awt.Window |
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus |
NEWLINE
protected static final String NEWLINE
Debug
public Debug()
Debug
public Debug(String title)
print
public static void print(String title,
Object obj)
- Print obj to the debug panel named title. If no such panel
exists, one will be created and added to the tab.
println
public static void println(String title,
Object obj)
- Print obj to the debug panel named title followed by a newline.
If no such panel exists, one will be created and added to the
tab.
note
public static void note(String msg)
- Println to the note tab.
error
public static void error(String msg)
- println to the Error tab and bring the debug window to the front.
makeActive
public static void makeActive(String title)
error
public static void error(Throwable exception)
- Print an exception to the Error tab and bring the debug window to the front.
- Parameters:
exception - a value of type Throwable
clear
public static void clear(String title)
addButton
public static void addButton(String title,
JButton button)
- Add a button to the bottom of the debug pane of the specified title.
addButton
public static void addButton(String title,
String buttonName,
ActionListener listener)
- Provide a listener and a button name and the Debug window will
create a button (at the bottom of the specified panel) and attach
the listener to it. This is usefull if you need to add one
button to several panels. e.g.:
ActionListener listener = new ActionListener() {
public void actionPerformed( ActionEvent e )
{
Test.test();
}
};
Debug.addButton( "Random1", "run test", listener );
Debug.addButton( "Random2", "run test", listener );
Debug.addButton( "Random3", "run test", listener );
getDebugFrame
public static JFrame getDebugFrame()
- Get the frame that houses the debug pane.
setDebugging
public static void setDebugging(boolean value)
isDebugging
public static boolean isDebugging(boolean value)
getDebugPanel
protected edu.mit.util.DebugPanel getDebugPanel(String title)
markDirty
public void markDirty(String title)
main
public static void main(String[] args)
- Test out the debug windows