public class Debug
extends java.lang.Object
To use, make sure that you call setStore() before anything else; it is a good idea to use a separate node to avoid name collisions:
 Debug.setStore(prefs.node("/debugFlags"));
 
 
 To allow user control at runtime, add a JMenu instance variable to your main menu, which constructs itself whenever it is called using the current set of flags, e.g.:
 JRootPane rootPane = getRootPaneContainer().getRootPane();
 JMenuBar mb = new JMenuBar();
 rootPane.setJMenuBar(mb);
 JMenu sysMenu = new JMenu("System");
 mb.add(sysMenu);
 
 JMenu debugMenu = (JMenu) sysMenu.add(new JMenu("Debug"));
 debugMenu.addMenuListener(new MenuListener() {
   public void menuSelected(MenuEvent e) {
     Debug.constructMenu(debugMenu);
   }
 
   public void menuDeselected(MenuEvent e) {}
 
   public void menuCanceled(MenuEvent e) {}
 });
 sysMenu.add(debugMenu);
 
 Then in your application code, check to see if a debug flag is turned on, for example:
 
 
 if (Debug.isSet("util/configure/stuff"))
   do_good_stuff();
 
 The first time this code is called, this flag will be added to the Store and to the menu (with a value of false). The user can then turn it on using the menu system. This allows you to add fine-grained debugging control without having to manage a separate list of flags. Since these are all static methods, you do not have to pass around a global Debug object. In this example, the top menu item to be added will be c alled "util" the second item called "configure", and the flag itself will be called "stuff". The menu may nest to arbitrary depth. Similarly, a substore of the main debug Store (the one passed into setStore()) is created called "util", which has a substore called "configure", which has a boolean value whose key is "stuff". Thus name collisions should be easy to avoid.
Preferences| Constructor and Description | 
|---|
Debug()  | 
| Modifier and Type | Method and Description | 
|---|---|
static void | 
constructMenu(javax.swing.JMenu topMenu)
Construct cascading pull-aside menus using the values of the debug flags
 in the Preferences object. 
 | 
static boolean | 
isSet(java.lang.String flagName)
Return the value of the named flag. 
 | 
static void | 
removeAll()
Clear all flags (set to false). 
 | 
static void | 
set(java.lang.String flagName,
   boolean value)
Set the value of the named flag. 
 | 
static void | 
setStore(java.util.prefs.Preferences debugStore)
Set the persistent data. 
 | 
public static void setStore(java.util.prefs.Preferences debugStore)
public static boolean isSet(java.lang.String flagName)
public static void set(java.lang.String flagName,
                       boolean value)
public static void removeAll()
public static void constructMenu(javax.swing.JMenu topMenu)
topMenu - attach the menus as children of this one.