Java Code Examples for java.awt.event.ActionEvent#getSource()
The following examples show how to use
java.awt.event.ActionEvent#getSource() .
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: StyledEditorKit.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Sets the font family. * * @param e the event */ public void actionPerformed(ActionEvent e) { JEditorPane editor = getEditor(e); if (editor != null) { String family = this.family; if ((e != null) && (e.getSource() == editor)) { String s = e.getActionCommand(); if (s != null) { family = s; } } if (family != null) { MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setFontFamily(attr, family); setCharacterAttributes(editor, attr, false); } else { UIManager.getLookAndFeel().provideErrorFeedback(editor); } } }
Example 2
Source File: ServiceDialog.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); boolean approved = false; if (source == btnApprove) { approved = true; if (pnlGeneral != null) { if (pnlGeneral.isPrintToFileRequested()) { approved = showFileChooser(); } else { asCurrent.remove(Destination.class); } } } dispose(approved ? APPROVE : CANCEL); }
Example 3
Source File: DomBuyRulePanel.java From DominionSim with MIT License | 6 votes |
@Override public void actionPerformed(ActionEvent aE) { if (aE.getActionCommand().equals( "Delete" )) { JButton theButton = (JButton) aE.getSource(); myBuyConditionPanels.remove(theButton.getParent()); fillConditionsPanel(); return; } if (aE.getActionCommand().equals( "add buy condition" )) { DomBuyCondition theDummyCondition = new DomBuyCondition(DomBotFunction.countCardsInDeck ,(DomCardName) myCardToBuyBox.getSelectedItem(), DomCardType.Action , "0" ,DomBotComparator.equalTo ,DomBotFunction.constant,DomCardName.Copper, DomCardType.Action, "0" , DomBotOperator.plus, "0") ; myBuyConditionPanels.add(theDummyCondition.getGuiPanel(this)); fillConditionsPanel(); return; } }
Example 4
Source File: StyledEditorKit.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Sets the foreground color. * * @param e the action event */ public void actionPerformed(ActionEvent e) { JEditorPane editor = getEditor(e); if (editor != null) { Color fg = this.fg; if ((e != null) && (e.getSource() == editor)) { String s = e.getActionCommand(); try { fg = Color.decode(s); } catch (NumberFormatException nfe) { } } if (fg != null) { MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, fg); setCharacterAttributes(editor, attr, false); } else { UIManager.getLookAndFeel().provideErrorFeedback(editor); } } }
Example 5
Source File: Compartments.java From iBioSim with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(ActionEvent e) { // if the add compartment type button is clicked // if the add species type button is clicked // if the add compartment button is clicked if (e.getSource() == addCompart) { compartEditor("Add",""); } // if the edit compartment button is clicked else if (e.getSource() == editCompart) { if (compartments.getSelectedIndex() == -1) { JOptionPane.showMessageDialog(Gui.frame, "Must Select a Compartment", "No compartment selected.",JOptionPane.ERROR_MESSAGE); return; } String selected = ((String) compartments.getSelectedValue()).split("\\[| ")[0]; compartEditor("OK",selected); initialsPanel.refreshInitialAssignmentPanel(bioModel); rulesPanel.refreshRulesPanel(); } // if the remove compartment button is clicked else if (e.getSource() == removeCompart) { removeCompartment(); } }
Example 6
Source File: RegistrationFrame.java From swift-k with Apache License 2.0 | 6 votes |
public void actionPerformed(ActionEvent e) { if (e.getSource() == submit) { try { panel.submit(false); JOptionPane.showMessageDialog(this, "Thank you for registering the Java CoG Kit", "Registration successful", JOptionPane.INFORMATION_MESSAGE); done(); } catch (IOException e1) { JOptionPane.showMessageDialog(this, "Could not submit registration information: " + e.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } else if (e.getSource() == cancel) { done(); } else { //must be the don't send switch submit.setEnabled(panel.getReregister().isSelected()); } }
Example 7
Source File: SkillDefaultEditor.java From gcs with Mozilla Public License 2.0 | 6 votes |
@Override public void actionPerformed(ActionEvent event) { Object src = event.getSource(); String command = event.getActionCommand(); if (SkillDefault.TAG_TYPE.equals(command)) { SkillDefaultType current = mDefault.getType(); SkillDefaultType value = (SkillDefaultType) ((JComboBox<?>) src).getSelectedItem(); if (current != value) { Commitable.sendCommitToFocusOwner(); mDefault.setType(value); rebuild(); notifyActionListeners(); } setLastItemType(value); } else { super.actionPerformed(event); } }
Example 8
Source File: AnnotationSettings.java From netbeans with Apache License 2.0 | 6 votes |
public void actionPerformed(ActionEvent evt) { if (evt.getSource() == panel.upButton) { onUpClick(); } else if (evt.getSource() == panel.downButton) { onDownClick(); } else if (evt.getSource() == panel.newButton) { onNewClick(); } else if (evt.getSource() == panel.removeButton) { onRemoveClick(); } else if (evt.getSource() == panel.editButton) { onEditClick(); } else if (evt.getSource() == panel.resetButton) { onResetClick(); } else if (evt.getSource() == panel.wizardButton) { onWizardClick(); } }
Example 9
Source File: CredentialsDialog.java From swift-k with Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { for (int i = 0; i < browse.length; i++) { if (e.getSource() == browse[i]) { choosePath(i); break; } } }
Example 10
Source File: VennDiagram.java From chipster with MIT License | 5 votes |
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if ( source == useButton ) { useButtonPressed(); } }
Example 11
Source File: GroundTruthTableWindow.java From thunderstorm with GNU General Public License v3.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { if(e.getSource() == evaluation) { MacroParser.runNestedWithRecording(PluginCommands.PERFORMANCE_EVALUATION.getValue(), null); } else if(e.getSource() == rendering) { new RenderingPlugIn().run(IJGroundTruthTable.IDENTIFIER); } else if(e.getSource() == showHist) { new IJDistribution().run(IJGroundTruthTable.IDENTIFIER); } else if(e.getSource() == io_import) { MacroParser.runNestedWithRecording(PluginCommands.IMPORT_GT.getValue(), null); } else if(e.getSource() == io_export) { MacroParser.runNestedWithRecording(PluginCommands.EXPORT_GT.getValue(), null); } }
Example 12
Source File: ProxyDialog.java From gepard with MIT License | 5 votes |
public void actionPerformed(ActionEvent evt) { if (evt.getSource() == btnOK) { // write to config Config.getInstance().setVal("proxy_host", txtHost.getText()); Config.getInstance().setVal("proxy_port", txtPort.getText()); // update system proxy settings ctrl.updateProxySettings(false); } // close dialog this.dispose(); }
Example 13
Source File: KeystoreOperation.java From cstc with GNU General Public License v3.0 | 5 votes |
@Override public void actionPerformed(ActionEvent arg0) { if( arg0.getSource() == keyStoreType ) { this.resetKeyStore(); } else if( arg0.getSource() == openKeyStoreButton ) { this.resetKeyStore(); this.openKeyStore(); } else if( arg0.getSource() == chooseFileButton ) { this.resetKeyStore(); int returnVal = fileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { keyStoreFile = fileChooser.getSelectedFile(); } } else if( arg0.getSource() == keyEntry ) { this.selectKeyEntry(); } if( keyStore != null && keyEntry != null ) { this.notifyChange(); } }
Example 14
Source File: ClientHandlerButtonListener.java From netbeans with Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent evt) { if (evt.getSource() == NotifyDescriptor.OK_OPTION) { RequestProcessor.getDefault().post(new Runnable() { public void run() { configureHandler(); } }); } }
Example 15
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void actionPerformed(ActionEvent e) { JCheckBox cb = (JCheckBox) e.getSource(); if (cb.isSelected()) { if (Objects.nonNull(cb.getIcon())) { cb.setIcon(null); cb.setSelected(false); } } else { cb.setIcon(icon); } }
Example 16
Source File: HistFrame.java From rest-client with Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JMenuItem) { this.menuItemPerformed(e); return; } if (e.getSource() instanceof JButton) { this.updateHist(); this.setVisible(false); } }
Example 17
Source File: NodeChooser.java From the-one with GNU General Public License v3.0 | 5 votes |
/** * Action listener method for buttons and node set chooser */ public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JButton) { JButton source = (JButton)e.getSource(); DTNHost host = (DTNHost)source.getClientProperty(HOST_KEY); gui.setFocus(host); } else if (e.getSource() == this.groupChooser) { setNodes(groupChooser.getSelectedIndex() * MAX_NODE_COUNT); } else if (e.getSource() == this.refreshTimer) { updateShownNodes(); } }
Example 18
Source File: NameGenPanel.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private void NameButtonActionPerformed(ActionEvent evt) { try { NameButton nb = (NameButton) evt.getSource(); DataElement element = nb.getDataElement(); element.getData(); Rule rule = this.lastRule; if (rule == null) { if (chkStructure.isSelected()) { RuleSet rs = (RuleSet) cbCatalog.getSelectedItem(); rule = rs.getLastRule(); } else { rule = (Rule) cbStructure.getSelectedItem(); } this.lastRule = rule; } List<DataValue> aName = rule.getLastData(); setNameText(aName); setMeaningText(aName); setPronounciationText(aName); } catch (Exception e) { Logging.errorPrint(e.getMessage(), e); } }
Example 19
Source File: LabeledTextFieldDialog.java From netbeans with Apache License 2.0 | 4 votes |
/** Creates new form LabeledTextFieldDialog */ public LabeledTextFieldDialog(String notes) { String title = NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableRenameTable"); // NOI18N String lab = NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableNewName"); // NOI18N original_notes = notes; initComponents(); try { Mnemonics.setLocalizedText(titleLabel, lab); titleLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableNewNameA11yDesc")); // NOI18N Mnemonics.setLocalizedText(descLabel, NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableRenameNotes")); // NOI18N descLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableRenameNotesA11yDesc")); // NOI18N Mnemonics.setLocalizedText(editButton, NbBundle.getMessage (LabeledTextFieldDialog.class, "EditCommand")); // NOI18N editButton.setToolTipText(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_EditCommandA11yDesc")); // NOI18N updateState(); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { result = event.getSource() == DialogDescriptor.OK_OPTION; } }; getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableDialogA11yDesc")); // NOI18N DialogDescriptor descriptor = new DialogDescriptor(this, title, true, listener); dialog = DialogDisplayer.getDefault().createDialog(descriptor); dialog.setResizable(true); } catch (MissingResourceException e) { e.printStackTrace(); } }
Example 20
Source File: mxGraphActions.java From consulo with Apache License 2.0 | 4 votes |
/** * */ public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof mxGraphComponent) { ((mxGraphComponent)e.getSource()).startEditing(); } }