List of usage examples for javax.swing.text JTextComponent getActions
@BeanProperty(bound = false)
public Action[] getActions()
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 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 w w w . jav a 2s . co 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: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 w w. j av a2s . 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: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); }//w w w . ja va 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()); } }
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 . java 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()); } }
From source file:Main.java
/** * Search the given text component's list of actions for an action with the given name. * Returns {@code null} if no such action is found. See {@link DefaultEditorKit} for a list of * action name constants./* w w w. j a va 2 s . c om*/ */ public static Action getAction(JTextComponent component, String actionName) { for (Action a : component.getActions()) { if (actionName.equals(a.getValue(Action.NAME))) { return a; } } return null; }
From source file:Main.java
public static HashMap<Object, Action> createActionTable(JTextComponent textComponent) { HashMap<Object, Action> actions = new HashMap<>(); Action[] actionsArray = textComponent.getActions(); for (int i = 0; i < actionsArray.length; i++) { Action a = actionsArray[i]; actions.put(a.getValue(Action.NAME), a); }/* w w w.j a va2s. com*/ return actions; }
From source file:Main.java
/** * initialize keystroke bindings/*from ww w . java 2 s.co m*/ */ public final static void InitializeKeyStrokeBindings() { String selectAllAction = DefaultEditorKit.selectAllAction; String cutAction = DefaultEditorKit.cutAction; String copyAction = DefaultEditorKit.copyAction; String pasteAction = DefaultEditorKit.pasteAction; int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); JTextComponent.KeyBinding ctrlA = new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A, mask), selectAllAction); JTextComponent.KeyBinding ctrlX = new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, mask), cutAction); JTextComponent.KeyBinding ctrlC = new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, mask), copyAction); JTextComponent.KeyBinding ctrlV = new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, mask), pasteAction); JTextComponent.KeyBinding[] extraBindings = new JTextComponent.KeyBinding[] { ctrlA, ctrlX, ctrlC, ctrlV }; Keymap defaultKeyMap = JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP); JTextComponent dummy = new JTextField(); JTextComponent.loadKeymap(defaultKeyMap, extraBindings, dummy.getActions()); }
From source file:Main.java
/** * Create a map view of {@code component.getActions()}, where the keys are the action * names. See {@link DefaultEditorKit} for a list of action name constants. *///w ww .j a va 2 s .co m public static Map<String, Action> getActions(JTextComponent component) { Map<String, Action> result = new HashMap<String, Action>(); for (Action a : component.getActions()) { // Documentation for Action.NAME asserts that it will always be a String result.put((String) a.getValue(Action.NAME), a); } return result; }
From source file:com.mirth.connect.client.ui.Mirth.java
private static void keyMapBindings(JTextComponent comp, KeyBinding[] bindings) { JTextComponent.loadKeymap(comp.getKeymap(), bindings, comp.getActions()); }