Java Code Examples for javafx.event.Event#getSource()

The following examples show how to use javafx.event.Event#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: CalculatorFXMLController.java    From dctb-utfpr-2018-1 with Apache License 2.0 11 votes vote down vote up
public void clickButtonNumbers(Event e) {
    if (e.getSource() == Bt1) {
        Equation.appendText("1");
    } else if (e.getSource() == Bt2) {
        Equation.appendText("2");
    } else if (e.getSource() == Bt3) {
        Equation.appendText("3");
    } else if (e.getSource() == Bt4) {
        Equation.appendText("4");
    } else if (e.getSource() == Bt5) {
        Equation.appendText("5");
    } else if (e.getSource() == Bt6) {
        Equation.appendText("6");
    } else if (e.getSource() == Bt7) {
        Equation.appendText("7");
    } else if (e.getSource() == Bt8) {
        Equation.appendText("8");
    } else if (e.getSource() == Bt9) {
        Equation.appendText("9");
    } else if (e.getSource() == Bt0) {
        Equation.appendText("0");
    } else if (e.getSource() == BtDot) {
        Equation.appendText(".");
    }

}
 
Example 2
Source File: CalculatorFXMLController.java    From dctb-utfpr-2018-1 with Apache License 2.0 8 votes vote down vote up
private void parseMethod(Event e) {
    if (e.getSource() == Btplus) {
        Equation.appendText(" + ");
    } else if (e.getSource() == BtMinus) {
        Equation.appendText(" - ");
    } else if (e.getSource() == BtX) {
        Equation.appendText(" x ");
    } else if (e.getSource() == BtDiv) {
        Equation.appendText(" / ");
    } else if (e.getSource() == BtAc) {
        Equation.setText("");
    } else if (e.getSource() == BtEqual) {
        resolve();
    }
}
 
Example 3
Source File: MainController.java    From MusicPlayer with MIT License 6 votes vote down vote up
@FXML
private void letterClicked(Event e) {
	
	sideBar.requestFocus();
	Label eventSource = ((Label)e.getSource());
	char letter = eventSource.getText().charAt(0);
	subViewController.scroll(letter);
}
 
Example 4
Source File: MainWindowController.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void handleSort(Event event) {
  if (!(event.getSource() instanceof ListView))
    return;
  ListView<?> sourceList = (ListView<?>) event.getSource();
  List<?> files = sourceList.getItems();
  files.sort(Ordering.usingToString());
}
 
Example 5
Source File: FlatTabPane.java    From oim-fx with MIT License 5 votes vote down vote up
private void tabOnMouseClicked(Event event) {
	Object o = event.getSource();
	if (o instanceof FlatTab) {
		FlatTab tabTemp = (FlatTab) o;
		selected(tabTemp);
	}
}
 
Example 6
Source File: TabPanel.java    From oim-fx with MIT License 5 votes vote down vote up
private void tabOnMouseClicked(Event event) {
	Object o = event.getSource();
	if (o instanceof Tab) {
		Tab tabTemp = (Tab) o;
		selected(tabTemp);
	}
}
 
Example 7
Source File: BibleSearchTreeView.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
private void trigger(Event t) {
    BibleSearchTreeView tv = (BibleSearchTreeView) t.getSource();
    TreeItem<BibleInterface> ti = tv.getSelectionModel().getSelectedItem();
    if (ti != null) {
        if (ti.getValue() instanceof BibleVerse) {
            textPane.getChildren().clear();
            BibleChapter chapter = (BibleChapter) ti.getValue().getParent();
            BibleVerse[] verses = chapter.getVerses();
            BibleVerse selected = (BibleVerse) ti.getValue();

            int x = selected.getNum() - 1;
            for (int i = 0; i < verses.length; i++) {
                Text text = new Text(verses[i].toString() + " ");
                text.getStyleClass().add("text");
                if (i == x) {
                    text.setFont(Font.font("Sans", FontWeight.BOLD, 14));
                } else {
                    text.setFont(Font.font("Sans", 14));
                }
                textPane.getChildren().add(text);
                text.wrappingWidthProperty().bind(sp.widthProperty().subtract(20)); //-20 to account for scroll bar width
            }
        } else {
            ti.setExpanded(!ti.isExpanded());
        }
    } else {
        tv.selectionModelProperty().get().selectFirst();
    }
}
 
Example 8
Source File: PortsSelectorController.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
private void handlePortSelectionChanged(Event event) {
    final PortCheckboxController checkBox = (PortCheckboxController) event.getSource();
    if (checkBox.isSelected()) {
        selectedPortIndexes.add(checkBox.getPortNumber());
    } else {
        selectedPortIndexes.remove(checkBox.getPortNumber());
    }

    handleFiltersUpdated();
}
 
Example 9
Source File: JavaFxRecorderHook.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void handleFolderChooser(Event event) {
    Node source = (Node) event.getSource();
    File folder = (File) source.getProperties().get("marathon.selectedFolder");
    new RFXFolderChooser(recorder).record(folder);
}
 
Example 10
Source File: JavaFxRecorderHook.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void handleFileChooser(Event event) {
    Node source = (Node) event.getSource();
    @SuppressWarnings("unchecked")
    List<File> selectedFiles = (List<File>) source.getProperties().get("marathon.selectedFiles");
    new RFXFileChooser(recorder).record(selectedFiles);
}
 
Example 11
Source File: StreamsSelectorController.java    From trex-stateless-gui with Apache License 2.0 4 votes vote down vote up
private void handleStreamDeleteClicked(final Event event) {
    final SelectedStreamController source = (SelectedStreamController) event.getSource();
    statsStorage.getPGIDsStorage().deselectPGID(source.getPGId());
}
 
Example 12
Source File: StreamsSelectorController.java    From trex-stateless-gui with Apache License 2.0 4 votes vote down vote up
private void handleStreamAddClicked(final Event event) {
    final StreamController source = (StreamController) event.getSource();
    statsStorage.getPGIDsStorage().selectPGID(source.getPGId());
}
 
Example 13
Source File: MainController.java    From Schillsaver with MIT License 4 votes vote down vote up
@Override
public void handle(final Event event) {
    final MainModel model = (MainModel) super.getModel();
    final MainView view = (MainView) super.getView();

    final Object source = event.getSource();

    if (source.equals(view.getButton_createJob())) {
        if (! view.getButton_createJob().isDisabled()) {
            openJobView();
            model.saveJobs();
        }

        return;
    }

    if (source.equals(view.getButton_editJob())) {
        if (! view.getButton_editJob().isDisabled()) {
            openEditJobView();
            model.saveJobs();
        }

        return;
    }

    if (source.equals(view.getButton_deleteSelectedJobs())) {
        if (! view.getButton_deleteSelectedJobs().isDisabled()) {
            deleteSelectedJobs();
            model.saveJobs();
        }

        return;
    }

    if (source.equals(view.getButton_processJobs())) {
        if (! view.getButton_processJobs().isDisabled()) {
            // Disable Buttons:
            view.getButton_createJob().setDisable(true);
            view.getButton_editJob().setDisable(true);
            view.getButton_deleteSelectedJobs().setDisable(true);
            view.getButton_processJobs().setDisable(true);
            view.getButton_programSettings().setDisable(true);

            final Endec endec = EndecFactory.create(EndecType.FFMPEG);

            final List<Thread> encodeJobs = endec.prepareEncodingJobs(this);
            final List<Thread> decodeJobs = endec.prepareDecodingJobs(this);

            final var thread = new Thread(() -> {
                processJobs(encodeJobs, decodeJobs);

                // Enable Buttons:
                view.getButton_createJob().setDisable(false);
                view.getButton_editJob().setDisable(false);
                view.getButton_deleteSelectedJobs().setDisable(false);
                view.getButton_processJobs().setDisable(false);
                view.getButton_programSettings().setDisable(false);
            });

            thread.start();
        }

        return;
    }

    if (source.equals(view.getButton_programSettings())) {
        if (view.getButton_programSettings().isDisabled() == false) {
            final SettingsModel settingsModel = new SettingsModel();
            final SettingsView settingsView = new SettingsView(settingsModel);
            final SettingsController settingsController = new SettingsController(settingsModel, settingsView);

            final Scene scene = new Scene(settingsView.getPane());
            scene.getStylesheets().add("global.css");
            scene.getRoot().getStyleClass().add("main-root");

            final Stage stage = new Stage();
            stage.setTitle("Settings");
            stage.setScene(scene);
            stage.initOwner(SceneManager.getInstance().getStage());
            stage.initModality(Modality.APPLICATION_MODAL);

            settingsController.setDialog(stage);

            stage.show();
        }
    }
}
 
Example 14
Source File: JobController.java    From Schillsaver with MIT License 4 votes vote down vote up
@Override
public void handle(final Event event) {
    final JobModel model = (JobModel) super.getModel();
    final JobView view = (JobView) super.getView();

    final Object source = event.getSource();

    if (source.equals(view.getButton_addFiles())) {
        addFiles();
        return;
    }

    if (source.equals(view.getButton_removeSelectedFiles())) {
        removeSelectedFiles();
        return;
    }

    if (source.equals(view.getButton_selectOutputFolder())) {
        selectOutputFolder();
        return;
    }

    if (source.equals(view.getButton_accept())) {
        final Controller previousController = SceneManager.getInstance().getPreviousController();
        final MainController controller = (MainController) previousController;

        if (model.getFiles().size() == 0) {
            SceneManager.getInstance().swapToPreviousScene();
            return;
        }

        final Job job = createJob();

        if (job != null) {
            controller.addJob(job);
            SceneManager.getInstance().swapToPreviousScene();
        }

        return;
    }

    if (source.equals(view.getButton_cancel())) {
        SceneManager.getInstance().swapToPreviousScene();
    }
}
 
Example 15
Source File: DesktopController.java    From CPUSim with GNU General Public License v3.0 2 votes vote down vote up
/**
 * If the user has unsaved content in a tab, this handles
 * asking the user if he would like to save it before closing.
 *
 * @param event unused action event
 */
@FXML
protected void handleTabClosed(Event event) {
    Tab closingTab = (Tab) event.getSource();
    closeTab(closingTab, false);
}