Listing the Actions in a Component
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.JButton;
public class Main {
public static void main(String[] argv) throws Exception {
JButton component = new JButton("button");
ActionMap map = component.getActionMap();
list(map, map.keys());
list(map, map.allKeys());
}
static void list(ActionMap map, Object[] actionKeys) {
if (actionKeys == null) {
return;
}
for (int i = 0; i < actionKeys.length; i++) {
// Get the action bound to this action key
while (map.get(actionKeys[i]) == null) {
map = map.getParent();
}
Action action = (Action) map.get(actionKeys[i]);
}
}
}
Related examples in the same category