public void loadBindingMap(InputMap im, ActionMap am) { results.append("Bound Actions\n"); String unboundActions = ""; String unboundInputKeys = ""; Hashtable mi = buildReverseMap(im); Object[] k = am.allKeys(); if (k != null) { for (int i = 0; i < k.length; i++) { if (mi.containsKey(k[i])) { results.append(" " + getActionName(k[i])); results.append(";" + mi.get(k[i]) + "\n"); } else { unboundActions += (" " + getActionName(k[i]) + "\n"); } } results.append("\nUnbound Actions\n\n"); results.append(unboundActions); } results.append("\nUnbound InputMap Entries\n"); k = im.allKeys(); if (k != null) { for (int i = 0; i < k.length; i++) { KeyStroke key = (KeyStroke) k[i]; Object actionKey = im.get(key); if (am.get(actionKey) == null) { results.append(" " + im.get((KeyStroke) k[i]) + ": " + k[i] + "\n"); } } } }
private Hashtable buildReverseMap(InputMap im) { KeyStroke k[] = im.allKeys(); Hashtable h = new Hashtable(); if (k != null) { for (int i = 0; i < k.length; i++) { Object nk = im.get(k[i]); Object cv = h.get(nk); if (h.containsKey(nk)) { ((Vector) cv).add(k[i]); } else { Vector v = new Vector(); v.add(k[i]); h.put(nk, v); } } } return h; }