Java Code Examples for java.awt.event.ActionEvent
The following examples show how to use
java.awt.event.ActionEvent.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: SampleTree.java License: GNU General Public License v2.0 | 8 votes |
/** * 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); } } }
Example #2
Source Project: netbeans Author: apache File: AbstractToolbarFactory.java License: Apache License 2.0 | 6 votes |
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); }
Example #3
Source Project: ganttproject Author: bardsoftware File: AssignmentDeleteAction.java License: GNU General Public License v3.0 | 6 votes |
@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(); } }); } } }
Example #4
Source Project: Java8CN Author: Java8-CNAPI-Team File: MenuComponent.java License: Apache License 2.0 | 6 votes |
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); } } }
Example #5
Source Project: buffer_bci Author: jadref File: DefaultPlotEditor.java License: GNU General Public License v3.0 | 6 votes |
/** * 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(); } }
Example #6
Source Project: brModelo Author: chcandido File: Editor.java License: GNU General Public License v3.0 | 6 votes |
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); } } } }
Example #7
Source Project: consulo Author: consulo File: ActionMenuItem.java License: Apache License 2.0 | 6 votes |
@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(); } }); }
Example #8
Source Project: netbeans Author: apache File: SettingsPanel.java License: Apache License 2.0 | 6 votes |
@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()); } }
Example #9
Source Project: ghidra Author: NationalSecurityAgency File: ChangedFilesDialog.java License: Apache License 2.0 | 6 votes |
/** * 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(); }
Example #10
Source Project: mars-sim Author: mars-sim File: SwingFXWebView.java License: GNU General Public License v3.0 | 6 votes |
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); }
Example #11
Source Project: dsworkbench Author: Torridity File: TroopTableTab.java License: Apache License 2.0 | 6 votes |
/** * 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()); }
Example #12
Source Project: nextreports-designer Author: nextreports File: SyntaxEditorKit.java License: Apache License 2.0 | 6 votes |
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); } }
Example #13
Source Project: pentaho-reporting Author: pentaho File: ExpressionMetaDataEditor.java License: GNU Lesser General Public License v2.1 | 6 votes |
/** * 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() ); }
Example #14
Source Project: CodenameOne Author: codenameone File: TimelineEditor.java License: GNU General Public License v2.0 | 6 votes |
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); } }
Example #15
Source Project: netbeans Author: apache File: TopComponentTest.java License: Apache License 2.0 | 6 votes |
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); }
Example #16
Source Project: visualvm Author: oracle File: FieldsBrowserControllerUI.java License: GNU General Public License v2.0 | 5 votes |
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(); } } }); }
Example #17
Source Project: ramus Author: Vitaliy-Yakovchuk File: ElistView.java License: GNU General Public License v3.0 | 5 votes |
@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(); }
Example #18
Source Project: rapidminer-studio Author: rapidminer File: SingleResultOverview.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override public void loggedActionPerformed(ActionEvent e) { ResultObject referenced = ioObject.get(); if (referenced != null) { RapidMinerGUI.getMainFrame().getResultDisplay().showResult(referenced); } }
Example #19
Source Project: mars-sim Author: mars-sim File: DynamicMenu.java License: GNU General Public License v3.0 | 5 votes |
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; }
Example #20
Source Project: workcraft Author: workcraft File: ColorComboBoxEditor.java License: MIT License | 5 votes |
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); } } }
Example #21
Source Project: petscii-bbs Author: sblendorio File: GameInfoDialog.java License: Mozilla Public License 2.0 | 5 votes |
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; }
Example #22
Source Project: sldeditor Author: robward-scisys File: ScaleTool.java License: GNU General Public License v3.0 | 5 votes |
/** 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)); }
Example #23
Source Project: netbeans Author: apache File: CloseButtonProvider.java License: Apache License 2.0 | 5 votes |
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; }
Example #24
Source Project: Spark Author: igniterealtime File: JavaMixer.java License: Apache License 2.0 | 5 votes |
public BooleanControlButtonModel(BooleanControl control) { this.control = control; this.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setSelected(!isSelected()); } }); }
Example #25
Source Project: PIPE Author: sarahtattersall File: RedoAction.java License: MIT License | 5 votes |
@Override public void actionPerformed(ActionEvent actionEvent) { PetriNetController controller = applicationController.getActivePetriNetController(); UndoManager manager = controller.getUndoManager(); manager.redo(); this.setEnabled(manager.canRedo()); undoAction.setEnabled(manager.canUndo()); }
Example #26
Source Project: pcgen Author: PCGen File: PurchaseInfoTab.java License: GNU Lesser General Public License v2.1 | 5 votes |
@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(); } }
Example #27
Source Project: pumpernickel Author: mickleness File: ColorWellUI.java License: MIT License | 5 votes |
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); } }
Example #28
Source Project: bigtable-sql Author: realXuJiang File: BaseSQLEntryPanel.java License: Apache License 2.0 | 5 votes |
/** * 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")); } }); } }
Example #29
Source Project: Cognizant-Intelligent-Test-Scripter Author: CognizantQAHub File: DriverSettings.java License: Apache License 2.0 | 5 votes |
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]); } } }
Example #30
Source Project: jplag Author: jplag File: MailDialog.java License: GNU General Public License v3.0 | 5 votes |
/** * 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; }