下面列出了java.awt.event.ActionEvent#getSource() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
/**
* 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);
}
}
}
@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;
}
}
/**
* 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);
}
}
}
@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();
}
}
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());
}
}
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();
}
}
@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);
}
}
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);
}
}
/**
* 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();
}
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() instanceof JMenuItem)
{
this.menuItemPerformed(e);
return;
}
if (e.getSource() instanceof JButton)
{
this.updateHist();
this.setVisible(false);
}
}
@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);
}
}
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() == NotifyDescriptor.OK_OPTION) {
RequestProcessor.getDefault().post(new Runnable() {
public void run() {
configureHandler();
}
});
}
}
@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();
}
}
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();
}
@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);
}
}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if ( source == useButton ) {
useButtonPressed();
}
}
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < browse.length; i++) {
if (e.getSource() == browse[i]) {
choosePath(i);
break;
}
}
}
/** 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();
}
}
/**
*
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof mxGraphComponent) {
((mxGraphComponent)e.getSource()).startEditing();
}
}