Java Swing Key Action getActionInstanceName(Action delegate)

Here you can find the source of getActionInstanceName(Action delegate)

Description

get Action Instance Name

License

Open Source License

Declaration

private static String getActionInstanceName(Action delegate) 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import javax.swing.Action;

public class Main {
    private static final String INSTANCE_PREFIX = "TransientAction-";
    private static final String INSTANCE_SUFFIX = ".instance";

    private static String getActionInstanceName(Action delegate) {
        Object commandKey = delegate.getValue(Action.ACTION_COMMAND_KEY);
        String id;//ww  w .  ja  va  2 s. c o m
        if (commandKey != null && !commandKey.toString().isEmpty()) {
            id = commandKey.toString();
        } else {
            id = delegate.getClass().getName();
        }
        id = id.replace('/', '-').replace('.', '-').replace('$', '-');
        if (!id.startsWith(INSTANCE_PREFIX)) {
            id = INSTANCE_PREFIX + id;
        }
        if (!id.endsWith(INSTANCE_SUFFIX)) {
            id += INSTANCE_SUFFIX;
        }
        return id;
    }
}

Related

  1. augmentList(Action[] list1, Action[] list2)
  2. dispatchEvent(final KeyEvent ke, final Component comp)
  3. escapeKeyAction(JComponent component, javax.swing.AbstractAction abstractAction)
  4. formatKeyStroke(final KeyStroke keyStroke)
  5. getActionID(final Action a)
  6. getEscapeKeystroke()
  7. getKeyStroke(int i0, int i1)
  8. getKeystroke(int keyevent)
  9. getKeyStrokeCopy()