类java.awt.event.ActionEvent源码实例Demo

下面列出了怎么用java.awt.event.ActionEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: netbeans   文件: AbstractToolbarFactory.java
public void actionPerformed (ActionEvent ae) {
    JComponent item = (JComponent) ae.getSource();
    String actionCommand = (String) item.getClientProperty(KEY_ACTION);
    String context = (String) item.getClientProperty(KEY_CONTAINERCTX);
    
    getEngine().notifyWillPerform (actionCommand, context);
    
    Action action = getEngine().getAction(context, actionCommand); 
    
    if (action.isEnabled()) {
        ActionEvent event = new ActionEvent (item, 
        ActionEvent.ACTION_PERFORMED, actionCommand);
        action.actionPerformed(event);
    }
    
    getEngine().notifyPerformed (actionCommand, context);
}
 
源代码2 项目: ganttproject   文件: AssignmentDeleteAction.java
@Override
public void actionPerformed(ActionEvent e) {
  final ResourceAssignment[] context = myContext.getResourceAssignments();
  if (context != null && context.length > 0) {
    Choice choice = myUIFacade.showConfirmationDialog(getI18n("msg23") + " " + StringUtils.getDisplayNames(context)
        + "?", getI18n("warning"));
    if (choice == Choice.YES) {
      myUIFacade.getUndoManager().undoableEdit(getLocalizedDescription(), new Runnable() {
        @Override
        public void run() {
          deleteAssignments(context);
          myUIFacade.refresh();
        }
      });
    }
  }
}
 
源代码3 项目: Java8CN   文件: MenuComponent.java
void dispatchEventImpl(AWTEvent e) {
    EventQueue.setCurrentEventAndMostRecentTime(e);

    Toolkit.getDefaultToolkit().notifyAWTEventListeners(e);

    if (newEventsOnly ||
        (parent != null && parent instanceof MenuComponent &&
         ((MenuComponent)parent).newEventsOnly)) {
        if (eventEnabled(e)) {
            processEvent(e);
        } else if (e instanceof ActionEvent && parent != null) {
            e.setSource(parent);
            ((MenuComponent)parent).dispatchEvent(e);
        }

    } else { // backward compatibility
        Event olde = e.convertToOld();
        if (olde != null) {
            postEvent(olde);
        }
    }
}
 
源代码4 项目: openjdk-jdk9   文件: SampleTree.java
/**
 * Removes the selected item as long as it isn't root.
 */
public void actionPerformed(ActionEvent e) {
    TreePath[] selected = getSelectedPaths();

    if (selected != null && selected.length > 0) {
        TreePath shallowest;

        // The remove process consists of the following steps:
        // 1 - find the shallowest selected TreePath, the shallowest
        //     path is the path with the smallest number of path
        //     components.
        // 2 - Find the siblings of this TreePath
        // 3 - Remove from selected the TreePaths that are descendants
        //     of the paths that are going to be removed. They will
        //     be removed as a result of their ancestors being
        //     removed.
        // 4 - continue until selected contains only null paths.
        while ((shallowest = findShallowestPath(selected)) != null) {
            removeSiblings(shallowest, selected);
        }
    }
}
 
源代码5 项目: buffer_bci   文件: DefaultPlotEditor.java
/**
     * Handles user actions generated within the panel.
     * @param event     the event
     */
    @Override
    public void actionPerformed(ActionEvent event) {
        String command = event.getActionCommand();
        if (command.equals("BackgroundPaint")) {
            attemptBackgroundPaintSelection();
        }
        else if (command.equals("OutlineStroke")) {
            attemptOutlineStrokeSelection();
        }
        else if (command.equals("OutlinePaint")) {
            attemptOutlinePaintSelection();
        }
//        else if (command.equals("Insets")) {
//            editInsets();
//        }
        else if (command.equals("Orientation")) {
            attemptOrientationSelection();
        }
        else if (command.equals("DrawLines")) {
            attemptDrawLinesSelection();
        }
        else if (command.equals("DrawShapes")) {
            attemptDrawShapesSelection();
        }
    }
 
源代码6 项目: brModelo   文件: Editor.java
public void DoAction(ActionEvent ev) {
    //setTextoDica("");
    if (diagramaAtual != null) {
        diagramaAtual.DoAction(ev);
        boolean eacao = false;
        Acao ac = null;
        if (((AbstractButton) ev.getSource()).getAction() instanceof Acao) {
            eacao = true;
            ac = (Acao) ((AbstractButton) ev.getSource()).getAction();
            try {
                setTextoDica(null, ac.getValue(Action.SHORT_DESCRIPTION).toString());
            } finally {
            }
        }
        if (ev.getSource() instanceof JMenuItem) {
            if (eacao) {
                controler.SelecioneForAction(ac);
            }
        }
    }
}
 
源代码7 项目: consulo   文件: ActionMenuItem.java
@Override
public void actionPerformed(final ActionEvent e) {
  final IdeFocusManager fm = IdeFocusManager.findInstanceByContext(myContext);
  final ActionCallback typeAhead = new ActionCallback();
  final String id = ActionManager.getInstance().getId(myAction.getAction());
  if (id != null) {
    FeatureUsageTracker.getInstance().triggerFeatureUsed("context.menu.click.stats." + id.replace(' ', '.'));
  }
  fm.typeAheadUntil(typeAhead, getText());
  fm.runOnOwnContext(myContext, () -> {
    final AnActionEvent event =
            new AnActionEvent(new MouseEvent(ActionMenuItem.this, MouseEvent.MOUSE_PRESSED, 0, e.getModifiers(), getWidth() / 2, getHeight() / 2, 1, false),
                              myContext, myPlace, myPresentation, ActionManager.getInstance(), e.getModifiers(), true, false);
    final AnAction menuItemAction = myAction.getAction();
    if (ActionUtil.lastUpdateAndCheckDumb(menuItemAction, event, false)) {
      ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
      actionManager.fireBeforeActionPerformed(menuItemAction, myContext, event);
      fm.doWhenFocusSettlesDown(typeAhead::setDone);
      ActionUtil.performActionDumbAware(menuItemAction, event);
      actionManager.queueActionPerformedEvent(menuItemAction, myContext, event);
    }
    else {
      typeAhead.setDone();
    }
  });
}
 
源代码8 项目: netbeans   文件: SettingsPanel.java
@Messages("TIT_CustomGradle=Select Gradle Distribution")
private void btUseCustomGradleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUseCustomGradleActionPerformed
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(Bundle.TIT_CustomGradle());
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setFileHidingEnabled(false);
    String path = tfUseCustomGradle.getText();
    if (path == null || path.trim().length() == 0) {
        path = GradleSettings.getDefault().getGradleUserHome().getAbsolutePath();
    }
    if (path.length() > 0) {
        File f = new File(path);
        if (f.exists()) {
            chooser.setSelectedFile(f);
        }
    }
    if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
        File distDir = chooser.getSelectedFile();
        tfUseCustomGradle.setText(distDir.getAbsolutePath());
    }
}
 
源代码9 项目: ghidra   文件: ChangedFilesDialog.java
/** 
 * Constructor 
 * @param tool tool to execute task and log messages in status window
 * @param list list of domain files that have changes
 */
public ChangedFilesDialog(PluginTool tool, ArrayList<DomainFile> list) { 
	super("Save Changed Files?", true);
	this.tool = tool;
	this.fileList = list;
	addWorkPanel(buildMainPanel());

	JButton saveButton = new JButton("Save");
	saveButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			save();
		}
	});
	saveButton.setToolTipText("Save files that have selected check boxes"); 
	addButton(saveButton);				
       addCancelButton();	
}
 
源代码10 项目: mars-sim   文件: SwingFXWebView.java
private void initComponents(){

        jfxPanel = new JFXPanel();
        createScene();

        setLayout(new BorderLayout());
        add(jfxPanel, BorderLayout.CENTER);

        swingButton = new JButton();
        swingButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Platform.runLater(new Runnable() {

                    @Override
                    public void run() {
                        webEngine.reload();
                    }
                });
            }
        });
        swingButton.setText("Reload");

        add(swingButton, BorderLayout.SOUTH);
    }
 
源代码11 项目: dsworkbench   文件: TroopTableTab.java
/**
 * Creates new form TroopTableTab
 *
 * @param pTroopSet
 * @param pActionListener
 */
public TroopTableTab(String pTroopSet, final ActionListener pActionListener) {
    actionListener = pActionListener;
    sTroopSet = pTroopSet;
    initComponents();
    jScrollPane1.setViewportView(jxTroopTable);
    mSupportDetailsDialog = new SupportDetailsDialog(DSWorkbenchTroopsFrame.getSingleton(), true);
    mTroopDetailsDialog = new TroopDetailsDialog(DSWorkbenchTroopsFrame.getSingleton(), true);
    if (!KEY_LISTENER_ADDED) {
        KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
        KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
        jxTroopTable.registerKeyboardAction(pActionListener, "Delete", delete, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        jxTroopTable.registerKeyboardAction(pActionListener, "BBCopy", bbCopy, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        jxTroopTable.getActionMap().put("find", new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent e) {
                pActionListener.actionPerformed(new ActionEvent(jxTroopTable, 0, "Find"));
            }
        });

        KEY_LISTENER_ADDED = true;
    }
    jxTroopTable.getSelectionModel().addListSelectionListener(TroopTableTab.this);
    //   jTroopAmountList.setCellRenderer(new TroopAmountListCellRenderer());
}
 
源代码12 项目: nextreports-designer   文件: SyntaxEditorKit.java
public void actionPerformed(ActionEvent event) {
    JTextComponent target = getTextComponent(event);
    if (target != null) {
        String line = SyntaxUtil.getLine(target);
        /**
         * Perform Smart Indentation:  pos must be on a line: this method will
         * use the previous lines indentation (number of spaces before any non-space
         * character or end of line) and return that as the prefix.
         */
        String indent = "";
        if (line != null && line.length() > 0) {
        	int i = 0;
        	while (i < line.length() && line.charAt(i) == ' ') {
        		i++;
        	}

        	indent = line.substring(0, i);
        }

        target.replaceSelection("\n" + indent);
    }
}
 
/**
 * Invoked when an action occurs.
 */
public void actionPerformed( final ActionEvent e ) {
  StringBuffer completeText = new StringBuffer();
  final int[] selectedRows = expressionsTable.getSelectedRows();
  for ( int i = 0; i < selectedRows.length; i++ ) {
    final int selectedRow = selectedRows[ i ];
    final int modelRow = expressionsTable.convertRowIndexToModel( selectedRow );
    final EditableExpressionMetaData data = metaData[ modelRow ];
    data.sort( expressionsTableModel.getLocale() );
    final String text = data.printBundleText( expressionsTableModel.getLocale() );
    System.out.println( "# Printing metadata for " + metaData[ modelRow ].getName() );
    System.out.println( text );
    completeText.append( "# Printing metadata for " + metaData[ modelRow ].getName() );
    completeText.append( "\n" );
    completeText.append( text );
  }

  dialog.showText( completeText.toString() );
}
 
源代码14 项目: CodenameOne   文件: TimelineEditor.java
private void addAnimationObjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addAnimationObjectActionPerformed
    AnimationObjectEditor editor = new AnimationObjectEditor(res, null, getValue(duration));
    editor.setStartTime(timeline.getValue());
    int ok = JOptionPane.showConfirmDialog(this, editor, "Add", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if(ok == JOptionPane.OK_OPTION) {
        ((AnimationObjectTableModel)animationObjectList.getModel()).addElement(editor.getAnimationObject());
        Timeline t = (Timeline)res.getImage(name);
        AnimationObject[] animations = new AnimationObject[t.getAnimationCount() + 1];
        for(int iter = 0 ; iter < animations.length - 1 ; iter++) {
            animations[iter] = t.getAnimation(iter);
        }
        animations[animations.length - 1] = editor.getAnimationObject();
        Timeline nt = Timeline.createTimeline(getValue(duration), animations,
                new com.codename1.ui.geom.Dimension(getValue(width), getValue(height)));
        nt.setPause(t.isPause());
        nt.setTime(t.getTime());
        setImage(nt);
    }
}
 
源代码15 项目: netbeans   文件: TopComponentTest.java
public void testCanTCGarbageCollectWhenActionInMapAndAssignLookup() {
    TopComponent tc = new TopComponent();
    class CAA extends AbstractAction implements
            ContextAwareAction {
        public void actionPerformed(ActionEvent arg0) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Action createContextAwareInstance(Lookup actionContext) {
            return this;
        }

    }
    tc.associateLookup(Lookups.fixed(tc.getActionMap(), tc));
    ContextAwareAction del = new CAA();
    ContextAwareAction context = Actions.context(Integer.class, true, true, del, null, "DisplayName", null, true);
    Action a = context.createContextAwareInstance(tc.getLookup());
    tc.getActionMap().put("key", a);

    WeakReference<Object> ref = new WeakReference<Object>(tc);
    tc = null;
    a = null;
    del = null;
    context = null;
    assertGC("Can the component GC?", ref);
}
 
源代码16 项目: visualvm   文件: FieldsBrowserControllerUI.java
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) {
    final boolean[] internalChange = new boolean[1];
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (internalChange[0]) return;
            final int column = Integer.parseInt(e.getActionCommand());
            if (column == 5 && !fieldsListTableModel.isRealColumnVisible(column)) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        final int retainedSizesState = fieldsBrowserController.getInstancesControllerHandler().
                                getHeapFragmentWalker().computeRetainedSizes(false, true);
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) {
                                    internalChange[0] = true;
                                    menuItem.setSelected(!menuItem.isSelected());
                                    internalChange[0] = false;
                                } else {
                                    fieldsListTableModel.setRealColumnVisibility(column,
                                            !fieldsListTableModel.isRealColumnVisible(column));
                                    fieldsListTable.createDefaultColumnsFromModel();
                                    fieldsListTable.updateTreeTableHeader();
                                    setColumnsData();
                                }
                            }
                        });
                    }
                });
            } else {
                fieldsListTableModel.setRealColumnVisibility(column,
                        !fieldsListTableModel.isRealColumnVisible(column));
                fieldsListTable.createDefaultColumnsFromModel();
                fieldsListTable.updateTreeTableHeader();
                setColumnsData();
            }
        }
    });
}
 
源代码17 项目: ramus   文件: ElistView.java
@Override
public void actionPerformed(ActionEvent e) {
    if (JOptionPane.showConfirmDialog(null, GlobalResourcesManager
                    .getString("DeleteActiveElementsDialog.Warning"),
            GlobalResourcesManager.getString("ConfirmMessage.Title"),
            JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
        return;
    component.deleteElements();
}
 
源代码18 项目: rapidminer-studio   文件: SingleResultOverview.java
@Override
public void loggedActionPerformed(ActionEvent e) {
	ResultObject referenced = ioObject.get();
	if (referenced != null) {
		RapidMinerGUI.getMainFrame().getResultDisplay().showResult(referenced);
	}
}
 
源代码19 项目: mars-sim   文件: DynamicMenu.java
protected WebDynamicMenu createMenu ()
{
    final WebDynamicMenu menu = new WebDynamicMenu ();
    menu.setType ( ( DynamicMenuType ) type.getSelectedItem () );
    menu.setHideType ( ( DynamicMenuType ) hidingType.getSelectedItem () );
    menu.setRadius ( Integer.parseInt ( radius.getText () ) );
    menu.setFadeStepSize ( 0.07f );

    final int items = Integer.parseInt ( amount.getText () );
    for ( int i = 1; i <= items; i++ )
    {
        final ImageIcon icon = WebLookAndFeel.getIcon ( 24 );
        final ActionListener action = new ActionListener ()
        {
            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                System.out.println ( icon );
            }
        };
        final WebDynamicMenuItem item = new WebDynamicMenuItem ( icon, action );
        item.setMargin ( new Insets ( 8, 8, 8, 8 ) );
        menu.addItem ( item );
    }

    return menu;
}
 
源代码20 项目: workcraft   文件: ColorComboBoxEditor.java
private void fireActionEvent(Color color) {
    Object[] listeners = listenerList.getListenerList();
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == ActionListener.class) {
            ActionEvent actionEvent = new ActionEvent(button, ActionEvent.ACTION_PERFORMED, color.toString());
            ((ActionListener) listeners[i + 1]).actionPerformed(actionEvent);
        }
    }
}
 
源代码21 项目: petscii-bbs   文件: GameInfoDialog.java
private JPanel createButtonPanel() {
  
  // Set up the other controls
  JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  JButton okButton = new JButton("Ok");
  okButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      setVisible(false);
    }
  });
  getRootPane().setDefaultButton(okButton);
  buttonPanel.add(okButton);
  return buttonPanel;
}
 
源代码22 项目: sldeditor   文件: ScaleTool.java
/** Creates the ui. */
private void createUI() {
    scaleGroupPanel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) scaleGroupPanel.getLayout();
    flowLayout.setVgap(0);
    flowLayout.setHgap(0);
    scaleGroupPanel.setBorder(
            BorderFactory.createTitledBorder(
                    Localisation.getString(ScaleTool.class, "ScaleTool.scale")));

    scaleButton =
            new ToolButton(
                    Localisation.getString(ScaleTool.class, "ScaleTool.scale"),
                    "tool/scaletool.png");
    scaleGroupPanel.add(scaleButton);
    scaleButton.setEnabled(false);
    scaleButton.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ScaleToolPanel scalePanel = new ScaleToolPanel(application);

                    scalePanel.populate(sldDataList);
                    scalePanel.setVisible(true);
                }
            });
    scaleGroupPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
 
源代码23 项目: netbeans   文件: CloseButtonProvider.java
public JButton create(final Runnable onClose) {
    JButton close = CloseButtonFactory.createBigCloseButton();
    if (onClose != null) close.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) { onClose.run(); }
    });
    return close;
}
 
源代码24 项目: Spark   文件: JavaMixer.java
public BooleanControlButtonModel(BooleanControl control) {
    this.control = control;
    this.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setSelected(!isSelected());
        }
    });
}
 
源代码25 项目: PIPE   文件: RedoAction.java
@Override
public void actionPerformed(ActionEvent actionEvent) {
    PetriNetController controller = applicationController.getActivePetriNetController();
    UndoManager manager = controller.getUndoManager();
    manager.redo();

    this.setEnabled(manager.canRedo());
    undoAction.setEnabled(manager.canUndo());
}
 
源代码26 项目: pcgen   文件: PurchaseInfoTab.java
@Override
public void actionPerformed(ActionEvent e)
{
	List<?> data = purchasedTable.getSelectedData();
	if (data != null)
	{
		for (Object object : data)
		{
			character.removePurchasedEquipment((EquipmentFacade) object, 1, false);
		}
		availableTable.refilter();
	}
}
 
源代码27 项目: pumpernickel   文件: ColorWellUI.java
public void actionPerformed(ActionEvent e) {
	JColorWell well = (JColorWell) e.getSource();
	Window owner = SwingUtilities.getWindowAncestor(well);
	Color newValue = JColorPicker.showDialog(owner, well
			.getColorSelectionModel().getSelectedColor());
	if (newValue != null) {
		well.getColorSelectionModel().setSelectedColor(newValue);
	}
}
 
源代码28 项目: bigtable-sql   文件: BaseSQLEntryPanel.java
/**
       * This provides the feature which is like in Eclipse when you control
       * click on an identifier it takes you to the file that contains the 
       * identifier (method, class, etc) definition.  Similarly, ctrl-clicking 
       * on an identifier in the SQL editor will invoke the view object at
       * cursor in object tree action. 
       */
@Override
      public void mouseClicked(MouseEvent e) {
          if (e.isControlDown() && e.getClickCount() == 1) {
              
              final Action a = 
                  _app.getActionCollection().get(ViewObjectAtCursorInObjectTreeAction.class);
              GUIUtils.processOnSwingEventThread(new Runnable() {
                  public void run() {
                      a.actionPerformed(new ActionEvent(this, 1, "ViewObjectAtCursorInObjectTreeAction"));
                  }
              });
          }
      }
 
private void removeCapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeCapActionPerformed
    int[] rows = capTable.getSelectedRows();
    if (rows != null) {
        DefaultTableModel model = (DefaultTableModel) capTable.getModel();
        for (int i = rows.length - 1; i >= 0; i--) {
            model.removeRow(rows[i]);
        }
    }
}
 
源代码30 项目: jplag   文件: MailDialog.java
/**
 * This method initializes jComboBox1	
 * 	
 * @return javax.swing.JComboBox	
 */    
private JComboBox<String> getJTagComboBox() {
	if (jTagComboBox == null) {
		jTagComboBox = new JComboBox<String>(tagNames);
		jTagComboBox.addActionListener(new java.awt.event.ActionListener() { 
			public void actionPerformed(java.awt.event.ActionEvent e) {
				JTextArea ta = getJTemplateTextArea();
				ta.insert("{" + (String) jTagComboBox.getSelectedItem() +
						"}",ta.getCaretPosition());
			}
		});
	}
	return jTagComboBox;
}