ui/src/main/java/ucar/util/prefs/ui/Debug.java
static private void addToMenu( JMenu menu, Preferences prefs) throws BackingStoreException {
    if (debug) System.out.println(" addMenu "+ prefs.name());

    String[] keys = prefs.keys();
    for (String key : keys) {
      boolean bval = prefs.getBoolean(key, false);
      String fullname = prefs.absolutePath() + "/" + key;
      menu.add(new DebugMenuItem(fullname, key, bval)); // menu leaf
      if (debug) System.out.println("   leaf= <" + key + "><" + fullname + ">");
    }

    String[] kidName = prefs.childrenNames();
    for (String aKidName : kidName) {
      Preferences pkid = prefs.node(aKidName);
      JMenu subMenu = new JMenu(pkid.name());
      menu.add(subMenu);
      addToMenu(subMenu, pkid);
    }
  }
static private void addToMenu( JMenu menu, Preferences prefs) throws BackingStoreException {
    if (debug) System.out.println(" addMenu "+ prefs.name());

    String[] keys = prefs.keys();
    for (String key : keys) {
      boolean bval = prefs.getBoolean(key, false);
      String fullname = prefs.absolutePath() + "/" + key;
      menu.add(new DebugMenuItem(fullname, key, bval)); // menu leaf
      if (debug) System.out.println("   leaf= <" + key + "><" + fullname + ">");
    }

    String[] kidName = prefs.childrenNames();
    for (String aKidName : kidName) {
      Preferences pkid = prefs.node(aKidName);
      JMenu subMenu = new JMenu(pkid.name());
      menu.add(subMenu);
      addToMenu(subMenu, pkid);
    }
  }
static private void addToMenu ( JMenu menu , Preferences prefs ) throws BackingStoreException { if ( debug ) System . out . println ( " addMenu " + prefs . name ( ) ) ; String [ ] keys = prefs . keys ( ) ; for ( String key : keys ) { boolean bval = prefs . getBoolean ( key , false ) ; String fullname = prefs . absolutePath ( ) + "/" + key ; menu . add ( new DebugMenuItem ( fullname , key , bval ) ) ; // menu leaf if ( debug ) System . out . println ( "   leaf= <" + key + "><" + fullname + ">" ) ; } String [ ] kidName = prefs . childrenNames ( ) ; for ( String aKidName : kidName ) { Preferences pkid = prefs . node ( aKidName ) ; JMenu subMenu = new JMenu ( pkid . name ( ) ) ; menu . add ( subMenu ) ; addToMenu ( subMenu , pkid ) ; } }
recursive menu adding
recursive menu adding