java.awt.event.ActionEvent Java Examples
The following examples show how to use
java.awt.event.ActionEvent.
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 File: SampleTree.java From openjdk-jdk9 with 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 File: AbstractToolbarFactory.java From netbeans with 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 File: AssignmentDeleteAction.java From ganttproject with 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 File: MenuComponent.java From Java8CN with 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 File: DefaultPlotEditor.java From buffer_bci with 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 File: Editor.java From brModelo with 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 File: ActionMenuItem.java From consulo with 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 File: SettingsPanel.java From netbeans with 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 File: ChangedFilesDialog.java From ghidra with 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 File: SwingFXWebView.java From mars-sim with 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 File: TroopTableTab.java From dsworkbench with 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 File: SyntaxEditorKit.java From nextreports-designer with 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 File: ExpressionMetaDataEditor.java From pentaho-reporting with 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 File: TimelineEditor.java From CodenameOne with 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 File: TopComponentTest.java From netbeans with 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 File: FieldsBrowserControllerUI.java From visualvm with 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 File: ElistView.java From ramus with 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 File: SingleResultOverview.java From rapidminer-studio with 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 File: DynamicMenu.java From mars-sim with 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 File: ColorComboBoxEditor.java From workcraft with 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 File: GameInfoDialog.java From petscii-bbs with 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 File: ScaleTool.java From sldeditor with 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 File: CloseButtonProvider.java From netbeans with 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 File: JavaMixer.java From Spark with 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 File: RedoAction.java From PIPE with 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 File: PurchaseInfoTab.java From pcgen with 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 File: ColorWellUI.java From pumpernickel with 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 File: BaseSQLEntryPanel.java From bigtable-sql with 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 File: DriverSettings.java From Cognizant-Intelligent-Test-Scripter with 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 File: MailDialog.java From jplag with 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; }