Search in sources :

Example 1 with Action

use of javax.swing.Action in project checkstyle by checkstyle.

the class MyAnnotation3 method holder.

/** methods in anonymous inner classes */
void holder() {
    Action a = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
        }

        void somethingElse(@MyAnnotation3 ActionEvent e) {
        }
    };
    Action b = new AbstractAction() {

        public void actionPerformed(final ActionEvent e) {
        }

        void somethingElse(@MyAnnotation3 final ActionEvent e) {
        }
    };
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction)

Example 2 with Action

use of javax.swing.Action in project pcgen by PCGen.

the class NotesView method rightJustifyButtonActionPerformed.

//GEN-LAST:event_sizeCBActionPerformed
private void rightJustifyButtonActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_rightJustifyButtonActionPerformed
    Action action = new StyledEditorKit.AlignmentAction("Right Justify", StyleConstants.ALIGN_RIGHT);
    action.actionPerformed(evt);
    editor.grabFocus();
    int cp = editor.getCaretPosition();
    updateButtons(editor, cp);
}
Also used : AlignmentAction(javax.swing.text.StyledEditorKit.AlignmentAction) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) AlignmentAction(javax.swing.text.StyledEditorKit.AlignmentAction) Point(java.awt.Point)

Example 3 with Action

use of javax.swing.Action in project intellij-community by JetBrains.

the class ScrollPaneActions method actionPerformed.

@Override
public void actionPerformed(AnActionEvent event) {
    JScrollPane pane = getScrollPane(event);
    if (pane == null)
        return;
    Action action = getSwingAction(pane);
    if (action == null)
        return;
    action.actionPerformed(new ActionEvent(pane, ActionEvent.ACTION_PERFORMED, mySwingActionId));
}
Also used : JScrollPane(javax.swing.JScrollPane) AnAction(com.intellij.openapi.actionSystem.AnAction) Action(javax.swing.Action) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ActionEvent(java.awt.event.ActionEvent)

Example 4 with Action

use of javax.swing.Action 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 5 with Action

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

the class HTMLEditor_MenuAction method createMenuBar.

//	setHTMLText
/**
	 * Create Menu Bar
	 */
private void createMenuBar() {
    //	Build Lookup
    Action[] actionArray = editorPane.getActions();
    Hashtable<Object, Action> actions = new Hashtable<Object, Action>();
    for (int i = 0; i < actionArray.length; i++) {
        Object name = actionArray[i].getValue(Action.NAME);
        //	System.out.println (name);
        actions.put(name, actionArray[i]);
    }
    for (int i = 0; i < extraActions.length; i++) {
        Object name = extraActions[i].getValue(Action.NAME);
        actions.put(name, extraActions[i]);
    }
    //	Add the font menu
    JMenu menu = buildMenu(Msg.getMsg(Env.getCtx(), "Font"), fontMenu, actions);
    if (menu != null)
        menuBar.add(menu);
    // Add the alignment menu
    menu = buildMenu(Msg.getMsg(Env.getCtx(), "Align"), alignMenu, actions);
    if (menu != null)
        menuBar.add(menu);
    // Add the HTML menu
    menu = buildMenu("HTML", htmlMenu, actions);
    if (menu != null)
        menuBar.add(menu);
    //	Add to Button Actions
    Action targetAction = (Action) actions.get("font-bold");
    bBold.addActionListener(targetAction);
    targetAction = (Action) actions.get("font-italic");
    bItalic.addActionListener(targetAction);
    targetAction = (Action) actions.get("font-underline");
    bUnderline.addActionListener(targetAction);
}
Also used : Action(javax.swing.Action) Hashtable(java.util.Hashtable) JMenu(javax.swing.JMenu)

Aggregations

Action (javax.swing.Action)249 AbstractAction (javax.swing.AbstractAction)168 ActionEvent (java.awt.event.ActionEvent)128 InputMap (javax.swing.InputMap)48 KeyStroke (javax.swing.KeyStroke)44 JPanel (javax.swing.JPanel)36 JMenu (javax.swing.JMenu)32 JPopupMenu (javax.swing.JPopupMenu)32 JButton (javax.swing.JButton)31 ArrayList (java.util.ArrayList)29 JRootPane (javax.swing.JRootPane)28 JMenuItem (javax.swing.JMenuItem)27 ActionMap (javax.swing.ActionMap)24 JScrollPane (javax.swing.JScrollPane)20 SwingAction (games.strategy.ui.SwingAction)19 BorderLayout (java.awt.BorderLayout)18 JDialog (javax.swing.JDialog)18 MouseEvent (java.awt.event.MouseEvent)16 Dimension (java.awt.Dimension)15 BoxLayout (javax.swing.BoxLayout)15