java.awt.event.ActionEvent#getSource()源码实例Demo

下面列出了java.awt.event.ActionEvent#getSource() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk8u-backup   文件: ServiceDialog.java
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);
}
 
源代码2 项目: jdk8u-jdk   文件: StyledEditorKit.java
/**
 * 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);
        }
    }
}
 
源代码3 项目: DominionSim   文件: DomBuyRulePanel.java
@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;
     }
}
 
源代码4 项目: openjdk-jdk8u   文件: StyledEditorKit.java
/**
 * 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);
        }
    }
}
 
源代码5 项目: iBioSim   文件: Compartments.java
@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();
	}
}
 
源代码6 项目: swift-k   文件: RegistrationFrame.java
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());
	}
}
 
源代码7 项目: netbeans   文件: AnnotationSettings.java
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();
    } 
}
 
源代码8 项目: gcs   文件: SkillDefaultEditor.java
@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);
    }
}
 
源代码9 项目: pcgen   文件: NameGenPanel.java
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);
	}
}
 
源代码10 项目: the-one   文件: NodeChooser.java
/**
 * 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();
	}
}
 
源代码11 项目: rest-client   文件: HistFrame.java
public void actionPerformed(ActionEvent e)
{
    if (e.getSource() instanceof JMenuItem)
    {
        this.menuItemPerformed(e);
        return;
    }

    if (e.getSource() instanceof JButton)
    {
        this.updateHist();
        this.setVisible(false);
    }
}
 
源代码12 项目: java-swing-tips   文件: MainPanel.java
@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);
  }
}
 
源代码13 项目: netbeans   文件: ClientHandlerButtonListener.java
public void actionPerformed(ActionEvent evt) {
    if (evt.getSource() == NotifyDescriptor.OK_OPTION) {
        RequestProcessor.getDefault().post(new Runnable() {

            public void run() {
                configureHandler();
            }
        });
    }
}
 
源代码14 项目: cstc   文件: KeystoreOperation.java
@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();
       }
}
 
源代码15 项目: gepard   文件: ProxyDialog.java
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();
	
}
 
源代码16 项目: thunderstorm   文件: GroundTruthTableWindow.java
@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);
    }
}
 
源代码17 项目: chipster   文件: VennDiagram.java
public void actionPerformed(ActionEvent e) {
	Object source = e.getSource();
	
	if ( source == useButton ) {
		useButtonPressed();		
	}
}
 
源代码18 项目: swift-k   文件: CredentialsDialog.java
public void actionPerformed(ActionEvent e) {
    for (int i = 0; i < browse.length; i++) {
        if (e.getSource() == browse[i]) {
            choosePath(i);
            break;
        }
    }
}
 
源代码19 项目: netbeans   文件: LabeledTextFieldDialog.java
/** 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();
    }

}
 
源代码20 项目: consulo   文件: mxGraphActions.java
/**
 *
 */
public void actionPerformed(ActionEvent e) {
  if (e.getSource() instanceof mxGraphComponent) {
    ((mxGraphComponent)e.getSource()).startEditing();
  }
}