Search in sources :

Example 6 with ActionMap

use of javax.swing.ActionMap in project adempiere by adempiere.

the class AdempiereTabbedPaneUI method installKeyboardActions.

protected void installKeyboardActions() {
    super.installKeyboardActions();
    // in the supper class, by our own.
    if (scrollableTabLayoutEnabled()) {
        Action forwardAction = new ScrollTabsForwardAction();
        Action backwardAction = new ScrollTabsBackwardAction();
        ActionMap am = SwingUtilities.getUIActionMap(tabPane);
        am.put("scrollTabsForwardAction", forwardAction);
        am.put("scrollTabsBackwardAction", backwardAction);
        tabScroller.scrollForwardButton.setAction(forwardAction);
        tabScroller.scrollBackwardButton.setAction(backwardAction);
    }
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionMap(javax.swing.ActionMap)

Example 7 with ActionMap

use of javax.swing.ActionMap in project adempiere by adempiere.

the class Util method printActionInputMap.

//	dump (Map)
/**
	 * Print Action and Input Map for component
	 * @param comp  Component with ActionMap
	 */
public static void printActionInputMap(JComponent comp) {
    //	Action Map
    ActionMap am = comp.getActionMap();
    //  including Parents
    Object[] amKeys = am.allKeys();
    if (amKeys != null) {
        System.out.println("-------------------------");
        System.out.println("ActionMap for Component " + comp.toString());
        for (int i = 0; i < amKeys.length; i++) {
            Action a = am.get(amKeys[i]);
            StringBuffer sb = new StringBuffer("- ");
            sb.append(a.getValue(Action.NAME));
            if (a.getValue(Action.ACTION_COMMAND_KEY) != null)
                sb.append(", Cmd=").append(a.getValue(Action.ACTION_COMMAND_KEY));
            if (a.getValue(Action.SHORT_DESCRIPTION) != null)
                sb.append(" - ").append(a.getValue(Action.SHORT_DESCRIPTION));
            System.out.println(sb.toString() + " - " + a);
        }
    }
    /**	Same as below
		KeyStroke[] kStrokes = comp.getRegisteredKeyStrokes();
		if (kStrokes != null)
		{
		System.out.println("-------------------------");
			System.out.println("Registered Key Strokes - " + comp.toString());
			for (int i = 0; i < kStrokes.length; i++)
			{
				System.out.println("- " + kStrokes[i].toString());
			}
		}
		/** Focused				*/
    InputMap im = comp.getInputMap(JComponent.WHEN_FOCUSED);
    KeyStroke[] kStrokes = im.allKeys();
    if (kStrokes != null) {
        System.out.println("-------------------------");
        System.out.println("InputMap for Component When Focused - " + comp.toString());
        for (int i = 0; i < kStrokes.length; i++) {
            System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString());
        }
    }
    /** Focused in Window	*/
    im = comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    kStrokes = im.allKeys();
    if (kStrokes != null) {
        System.out.println("-------------------------");
        System.out.println("InputMap for Component When Focused in Window - " + comp.toString());
        for (int i = 0; i < kStrokes.length; i++) {
            System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString());
        }
    }
    /** Focused when Ancester	*/
    im = comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    kStrokes = im.allKeys();
    if (kStrokes != null) {
        System.out.println("-------------------------");
        System.out.println("InputMap for Component When Ancestor - " + comp.toString());
        for (int i = 0; i < kStrokes.length; i++) {
            System.out.println("- " + kStrokes[i].toString() + " - " + im.get(kStrokes[i]).toString());
        }
    }
    System.out.println("-------------------------");
}
Also used : Action(javax.swing.Action) ActionMap(javax.swing.ActionMap) KeyStroke(javax.swing.KeyStroke) InputMap(javax.swing.InputMap)

Example 8 with ActionMap

use of javax.swing.ActionMap in project jmeter by apache.

the class SelectTemplatesDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    // Hide Window on ESC
    Action escapeAction = new //$NON-NLS-1$
    AbstractAction(//$NON-NLS-1$
    "ESCAPE") {

        /**
             *
             */
        private static final long serialVersionUID = -6543764044868772971L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    // Do search on Enter
    Action enterAction = new //$NON-NLS-1$
    AbstractAction(//$NON-NLS-1$
    "ENTER") {

        private static final long serialVersionUID = -3661361497864527363L;

        @Override
        public void actionPerformed(final ActionEvent actionEvent) {
            checkDirtyAndLoad(actionEvent);
        }
    };
    ActionMap actionMap = rootPane.getActionMap();
    actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
    actionMap.put(enterAction.getValue(Action.NAME), enterAction);
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
    inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME));
    return rootPane;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 9 with ActionMap

use of javax.swing.ActionMap in project jmeter by apache.

the class RowDetailDialog method createRootPane.

@Override
protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    // Hide Window on ESC
    Action escapeAction = new AbstractAction("ESCAPE") {

        private static final long serialVersionUID = -8699034338969407625L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    };
    // Do update on Enter
    Action enterAction = new AbstractAction("ENTER") {

        private static final long serialVersionUID = -1529005452976176873L;

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            doUpdate(actionEvent);
            setVisible(false);
        }
    };
    ActionMap actionMap = rootPane.getActionMap();
    actionMap.put(escapeAction.getValue(Action.NAME), escapeAction);
    actionMap.put(enterAction.getValue(Action.NAME), enterAction);
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME));
    inputMap.put(KeyStrokes.ENTER, enterAction.getValue(Action.NAME));
    return rootPane;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) JRootPane(javax.swing.JRootPane) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 10 with ActionMap

use of javax.swing.ActionMap in project jmeter by apache.

the class SearchTreePanel method init.

private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    setLayout(new BorderLayout(10, 10));
    //$NON-NLS-1$
    searchTF = new JTextField(20);
    InputMap im = searchTF.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(KeyStrokes.ENTER, SEARCH_TEXT_COMMAND);
    ActionMap am = searchTF.getActionMap();
    am.put(SEARCH_TEXT_COMMAND, new EnterAction());
    //$NON-NLS-1$
    isRegexpCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_regexp"), false);
    //$NON-NLS-1$
    isCaseSensitiveCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_case"), false);
    isRegexpCB.setFont(FONT_SMALL);
    isCaseSensitiveCB.setFont(FONT_SMALL);
    //$NON-NLS-1$
    searchButton = new JButton(JMeterUtils.getResString("search"));
    searchButton.addActionListener(this);
    //$NON-NLS-1$
    resetButton = new JButton(JMeterUtils.getResString("reset"));
    resetButton.addActionListener(this);
    JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    searchPanel.add(new JLabel(JMeterUtils.getResString("search_text_field")));
    searchPanel.add(searchTF);
    searchPanel.add(isCaseSensitiveCB);
    searchPanel.add(isRegexpCB);
    searchPanel.add(searchButton);
    searchPanel.add(resetButton);
    add(searchPanel);
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) ActionMap(javax.swing.ActionMap) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) InputMap(javax.swing.InputMap) JTextField(javax.swing.JTextField)

Aggregations

ActionMap (javax.swing.ActionMap)45 InputMap (javax.swing.InputMap)38 AbstractAction (javax.swing.AbstractAction)24 ActionEvent (java.awt.event.ActionEvent)20 Action (javax.swing.Action)14 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 JButton (javax.swing.JButton)11 BorderLayout (java.awt.BorderLayout)9 JDialog (javax.swing.JDialog)8 JPanel (javax.swing.JPanel)8 JScrollPane (javax.swing.JScrollPane)7 JComponent (javax.swing.JComponent)6 JTextField (javax.swing.JTextField)6 FormBuilder (com.jgoodies.forms.builder.FormBuilder)5 FormLayout (com.jgoodies.forms.layout.FormLayout)5 Component (java.awt.Component)3 Insets (java.awt.Insets)3 List (java.util.List)3 JCheckBox (javax.swing.JCheckBox)3 FlowLayout (java.awt.FlowLayout)2