Java Code Examples for javafx.event.ActionEvent#getTarget()

The following examples show how to use javafx.event.ActionEvent#getTarget() . 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: FxAction.java    From FxDock with Apache License 2.0 6 votes vote down vote up
/** override to obtain the ActionEvent */
public void handle(ActionEvent ev)
{
	if(isEnabled())
	{
		if(ev != null)
		{
			if(ev.getSource() instanceof Menu)
			{
				if(ev.getSource() != ev.getTarget())
				{
					// selection of a cascading child menu triggers action event for the parent 
					// for some unknown reason.  ignore this.
					return;
				}
			}
			
			ev.consume();
		}
		
		execute();
	}
}
 
Example 2
Source File: Synchronization.java    From PeerWasp with MIT License 5 votes vote down vote up
/**
 * This method is bound to the fxml of the view and is invoked
 * by clicks on the "Cancel" button.
 * @param event that was fired.
 */
@FXML
public void cancelAction(ActionEvent event) {
	if(event.getTarget() != null && event.getTarget() instanceof Button){
		Button cancelButton = (Button)event.getTarget();
		Window window = cancelButton.getScene().getWindow();
		window.hide();
	}
}
 
Example 3
Source File: Properties.java    From PeerWasp with MIT License 5 votes vote down vote up
@FXML
public void okAction(ActionEvent event) {
	if(event.getTarget() != null && event.getTarget() instanceof Button){
		Button okButton = (Button)event.getTarget();
		Window window = okButton.getScene().getWindow();
		window.hide();
	}
}