Example usage for javax.swing Action NAME

List of usage examples for javax.swing Action NAME

Introduction

In this page you can find the example usage for javax.swing Action NAME.

Prototype

String NAME

To view the source code for javax.swing Action NAME.

Click Source Link

Document

The key used for storing the String name for the action, used for a menu or button.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton();
    MyAction action = new MyAction();
    component.getActionMap().put(action.getValue(Action.NAME), action);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton();
    MyAction action = new MyAction();

    component.getActionMap().put(action.getValue(Action.NAME), action);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JButton component = new JButton();

    MyAction action = new MyAction();
    component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F2"),
            action.getValue(Action.NAME));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JTextArea component = new JTextArea();

    NextFocusAction nextFocusAction = new NextFocusAction();
    PrevFocusAction prevFocusAction = new PrevFocusAction();

    component.getActionMap().put(nextFocusAction.getValue(Action.NAME), nextFocusAction);
    component.getActionMap().put(prevFocusAction.getValue(Action.NAME), prevFocusAction);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JButton component = new JButton();
    MyAction action = new MyAction();

    component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F2"),
            action.getValue(Action.NAME));
}

From source file:Main.java

public static void main(String[] argv) {
    JButton component = new JButton();
    PrevFocusAction prevFocusAction = new PrevFocusAction();
    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("shift F2"),
            prevFocusAction.getValue(Action.NAME));
    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("shift SPACE"),
            prevFocusAction.getValue(Action.NAME));
    component.getActionMap().put(prevFocusAction.getValue(Action.NAME), prevFocusAction);
}

From source file:Main.java

public static void main(String[] argv) {
    JButton component = new JButton();
    NextFocusAction nextFocusAction = new NextFocusAction();

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("SPACE"),
            nextFocusAction.getValue(Action.NAME));

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("F2"),
            nextFocusAction.getValue(Action.NAME));

    component.getActionMap().put(nextFocusAction.getValue(Action.NAME), nextFocusAction);

}

From source file:Main.java

public static void main(String args[]) {
    JTextComponent component = new JTextArea();

    // Process action list
    Action actions[] = component.getActions();
    // Define comparator to sort actions
    Comparator<Action> comparator = new Comparator<Action>() {
        public int compare(Action a1, Action a2) {
            String firstName = (String) a1.getValue(Action.NAME);
            String secondName = (String) a2.getValue(Action.NAME);
            return firstName.compareTo(secondName);
        }//from  w  w  w.j ava2s  . com
    };
    Arrays.sort(actions, comparator);

    int count = actions.length;
    System.out.println("Count: " + count);
    for (int i = 0; i < count; i++) {
        System.out.printf("%28s : %s\n", actions[i].getValue(Action.NAME), actions[i].getClass().getName());
    }
}

From source file:Main.java

public static void main(String args[]) {
    JTextComponent component = new JTextField();

    // Process action list
    Action actions[] = component.getActions();
    // Define comparator to sort actions
    Comparator<Action> comparator = new Comparator<Action>() {
        public int compare(Action a1, Action a2) {
            String firstName = (String) a1.getValue(Action.NAME);
            String secondName = (String) a2.getValue(Action.NAME);
            return firstName.compareTo(secondName);
        }/*from   w ww  .  j a  v  a 2 s  . c  o  m*/
    };
    Arrays.sort(actions, comparator);

    int count = actions.length;
    System.out.println("Count: " + count);
    for (int i = 0; i < count; i++) {
        System.out.printf("%28s : %s\n", actions[i].getValue(Action.NAME), actions[i].getClass().getName());
    }
}

From source file:ListActionsJTextPane.java

public static void main(String args[]) {
    JTextComponent component = new JTextPane();

    // Process action list
    Action actions[] = component.getActions();
    // Define comparator to sort actions
    Comparator<Action> comparator = new Comparator<Action>() {
        public int compare(Action a1, Action a2) {
            String firstName = (String) a1.getValue(Action.NAME);
            String secondName = (String) a2.getValue(Action.NAME);
            return firstName.compareTo(secondName);
        }//from ww  w  . ja v  a  2s.  c  o m
    };
    Arrays.sort(actions, comparator);

    int count = actions.length;
    System.out.println("Count: " + count);
    for (int i = 0; i < count; i++) {
        System.out.printf("%28s : %s\n", actions[i].getValue(Action.NAME), actions[i].getClass().getName());
    }
}