Java Swing ActionMap dumpActionMap(JComponent comp)

Here you can find the source of dumpActionMap(JComponent comp)

Description

dump Action Map

License

Apache License

Declaration

public static void dumpActionMap(JComponent comp) 

Method Source Code

//package com.java2s;
/*/*  w  w w  .  ja va 2  s .  c  om*/
 * WbSwingUtilities.java
 *
 * This file is part of SQL Workbench/J, http://www.sql-workbench.net
 *
 * Copyright 2002-2015, Thomas Kellerer
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at.
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * To contact the author please send an email to: support@sql-workbench.net
 *
 */

import javax.swing.*;

public class Main {
    public static void dumpActionMap(JComponent comp) {
        System.out
                .println("InputMap for WHEN_ANCESTOR_OF_FOCUSED_COMPONENT");
        System.out
                .println("-----------------------------------------------");
        dumpInputMap(comp
                .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));

        System.out.println("\nInputMap for WHEN_FOCUSED");
        System.out.println("-------------------------");
        dumpInputMap(comp.getInputMap(JComponent.WHEN_FOCUSED));

        System.out.println("\nInputMap for WHEN_IN_FOCUSED_WINDOW");
        System.out.println("-----------------------------------");
        dumpInputMap(comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    }

    private static void dumpInputMap(InputMap im) {
        if (im != null && im.allKeys() != null) {
            for (KeyStroke key : im.allKeys()) {
                if (key == null)
                    continue;
                Object o = im.get(key);
                System.out.println("key: " + key + " mapped to "
                        + o.toString());
            }
        } else {
            System.out.println("Nothing mapped");
        }
    }
}

Related

  1. addFieldValidateAction(JComponent field, Action action)
  2. attachAccelerator(Action action, JComponent component)
  3. bindAction(JComponent aComponent, String aCommand, Action anAction)
  4. checkActions(JComponent aComponent)
  5. cloneActionMap(ActionMap original)
  6. fillInputMap(ActionMap am)
  7. installActions(JComponent comp, Action actions[], int condition)
  8. printActionInputMap(JComponent comp)
  9. printActionMap(ActionMap actionMap, String who)