Example usage for javax.swing Action getValue

List of usage examples for javax.swing Action getValue

Introduction

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

Prototype

public Object getValue(String key);

Source Link

Document

Gets one of this object's properties using the associated key.

Usage

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);
        }// w  w w .  j  av a2 s .  c om
    };
    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  va2s  .  c om
    };
    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. j  a v a 2 s . 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:ListActionsJPasswordField.java

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

    // 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 .j a v  a2 s.  c om*/
    };
    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:ListActionsJEditorPane.java

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

    // 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 a  v  a2  s .  c  om*/
    };
    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[] argv) throws Exception {
    final Action action = new AbstractAction("Action Name") {
        public void actionPerformed(ActionEvent evt) {
            System.out.println("action");
        }/* w  w  w . j  av a 2s.  c  om*/
    };

    JFrame frame = new JFrame();
    JButton button = new JButton(action);

    JTextField textfield = new JTextField();
    textfield.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("F2"),
            action.getValue(Action.NAME));
    textfield.getActionMap().put(action.getValue(Action.NAME), action);
}

From source file:Main.java

public static void mapAction(JComponent c, int condition, KeyStroke keyStroke, Action action) {
    Object key = action.getValue(Action.NAME);
    if (key == null)
        throw new IllegalArgumentException("The provided action must " + "have a name defined");
    mapAction(c, condition, key, keyStroke, action);
}

From source file:CutPasteSample.java

private static Action findAction(Action actions[], String key) {
    Hashtable<Object, Action> commands = new Hashtable<Object, Action>();
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        commands.put(action.getValue(Action.NAME), action);
    }//from  ww  w .ja v a  2  s  .  co  m
    return commands.get(key);
}

From source file:CutPasteSample.java

public static Action findAction(Action actions[], String key) {
    Hashtable commands = new Hashtable();
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        commands.put(action.getValue(Action.NAME), action);
    }/*w w w.  j a va 2 s . c  o m*/
    return (Action) commands.get(key);
}

From source file:Main.java

public static void bindAction(JComponent aComponent, String aCommand, Action anAction) {
    Object o = anAction.getValue(Action.ACCELERATOR_KEY);
    if (o instanceof KeyStroke)
        bindAction(aComponent, aCommand, anAction, (KeyStroke) o);
    else/*from   w w w  .  j  a  va  2 s .c  o  m*/
        throw new IllegalArgumentException("Can not bind action, it has no keystroke assigned.");
}