// Look up the Action cache associated with this bundle
HashMap cache = (HashMap) bundleToCacheMap.get(bundle);
if (cache == null) { // If there isn't one, create one and save it
cache = new HashMap();
bundleToCacheMap.put(bundle, cache);
}
// Now look up the Action associated with the key in the cache.
Action action = (Action) cache.get(key);
// If we found a cached action, return it.
if (action != null) return action;
// If there was no cached action create one. The command is
// the only required resource. It will throw an exception if
// missing or malformed.
Command command = (Command) bundle.getResource(key, Command.class);
// The remaining calls all supply default values, so they will not
// throw exceptions, even if ResourceParsers haven't been registered
// for types like Icon and KeyStroke
String label = bundle.getString(key + ".label", null);
Icon icon = (Icon) bundle.getResource(key + ".icon", Icon.class, null);
String tooltip = bundle.getString(key + ".description", null);
KeyStroke accelerator =
(KeyStroke) bundle.getResource(key + ".accelerator",
KeyStroke.class, null);
int mnemonic = bundle.getInt(key + ".mnemonic", KeyEvent.VK_UNDEFINED);
boolean enabled = bundle.getBoolean(key + ".enabled", true);
// Create a CommandAction object with these values
action = new CommandAction(command, label, icon, tooltip,
accelerator, mnemonic, enabled);
// Save it in the cache, then return it
cache.put(key, action);
return action;