Example usage for javafx.event ActionEvent getSource

List of usage examples for javafx.event ActionEvent getSource

Introduction

In this page you can find the example usage for javafx.event ActionEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:com.loop81.fxcomparer.FXComparerController.java

@FXML
protected void onSelectFile2(ActionEvent event) {
    event.consume();/*from w  w w .  j av  a2  s. co  m*/
    archive2 = selectFile(((Node) event.getSource()).getScene().getWindow());
    handleFile(archive2, textFieldArchive2, labelArchive2Info);
}

From source file:com.bdb.weather.display.preferences.ColorPreferencePanel.java

public ColorPreferencePanel() {
    VBox vbox = new VBox();
    GridPane colorPanel = new GridPane();

    for (ColorPreferenceEntry entry : entries2) {
        ColorPicker colorPicker = new ColorPicker(preferences.getColorPref(entry.preferenceName));
        entry.button = colorPicker;//from w  w  w. j  a v a 2s.  c  o  m
        colorPanel.add(new Label(entry.preferenceName), 0, entry.row);
        colorPanel.add(colorPicker, 1, entry.row);
    }

    GridPane plotColorPanel = new GridPane();

    int gridx = 0;
    int gridy = 0;

    //
    // Layout the column headers
    //
    for (int i = 0; i < COLOR_COL_HEADERS.length; i++) {
        gridx = i;
        plotColorPanel.add(new Label(COLOR_COL_HEADERS[i]), gridx, gridy);
    }

    //
    // Layout the row leaders
    //
    //c.anchor = GridBagConstraints.EAST;
    for (String header : COLOR_ROW_HEADERS) {
        gridx = 0;
        gridy++;
        plotColorPanel.add(new Label(header), gridx, gridy);

        gridx = 5;

        Set<String> names = ColorSchemeCollection.getColorSchemeNames();
        ComboBox<String> scheme = new ComboBox<>();
        scheme.getItems().addAll(names);
        scheme.setUserData(gridy);
        plotColorPanel.add(scheme, gridx, gridy);
        scheme.setOnAction((ActionEvent e) -> {
            ComboBox<String> cb = (ComboBox<String>) e.getSource();
            applyColorScheme((Integer) cb.getUserData(), cb.getSelectionModel().getSelectedItem());
        });
        gridx = 6;
        CheckBox showSeries = new CheckBox();
        showSeries.setUserData(gridy);
        plotColorPanel.add(showSeries, gridx, gridy);
        showSeries.setOnAction((ActionEvent e) -> {
            CheckBox cb = (CheckBox) e.getSource();
            int row = (Integer) cb.getUserData();
            for (ColorPreferenceEntry entry : entries) {
                if (entry.row == row) {
                    addRemoveSeries(entry.preferenceName, cb.isSelected());
                }
            }
            createSeriesData();
            configureRenderer();
        });
    }

    //c.anchor = GridBagConstraints.CENTER;
    for (ColorPreferenceEntry entry : entries) {
        gridx = entry.column;
        gridy = entry.row;
        ColorPicker button = new ColorPicker();
        button.setValue(preferences.getColorPref(entry.preferenceName));
        //button.setPrefSize(10, 10);
        button.setUserData(entry);
        plotColorPanel.add(button, gridx, gridy);
        entry.button = button;
    }

    JFreeChart chart = ChartFactory.createXYLineChart("Example", "X Axis", "Y Axis", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(renderer);

    ChartViewer graphExamplePanel = new ChartViewer(chart);

    vbox.getChildren().addAll(colorPanel, plotColorPanel);
    setTop(vbox);
    setCenter(graphExamplePanel);
    FlowPane buttonPanel = new FlowPane();
    Button button = new Button("OK");
    button.setOnAction((ActionEvent e) -> {
        saveData();
    });
    buttonPanel.getChildren().add(button);
    setBottom(buttonPanel);
}

From source file:ambroafb.clients.dialog.ClientDialogController.java

private void switchJuridical(ActionEvent e) {
    String delimiter = " ";
    if (((CheckBox) e.getSource()).isSelected()) {
        changeSceneVisualAsFirm(delimiter);
    } else {//from ww w  .ja v  a2s  .com
        changeSceneVisualAsPerson(delimiter);
    }
}

From source file:aajavafx.EmployeeController.java

@FXML
private void handleGoBack(ActionEvent event) {
    //labelError.setText(null);
    try {//from w w  w.j  a v a 2 s .com
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPageTab.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root, 879, 599);
        stage.setScene(scene);

        stage.setTitle("Main menu");
        stage.show();

    } catch (Exception ex) {
        Logger.getLogger(MainPageController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.bdb.weather.display.day.DayXYPlotPane.java

/**
 * Process the change in state of the day/night indicator selection
 * @param event//from  ww w.  j  av  a 2 s.c o  m
 */
@Override
public void handle(ActionEvent event) {
    if (event.getSource() == dayNightItem) {
        displayDayNightIndicators = dayNightItem.isSelected();
        addSunriseSunsetMarkers();
        return;
    }

    for (SeriesEntry entry : entries) {
        if (event.getSource() == entry.checkbox) {
            displaySeries(datasetLeft, datasetRight);
            break;
        }
    }
}

From source file:aajavafx.VisitorScheduleController.java

@FXML
private void handleBackButton(ActionEvent event) {
    try {//w w  w  .java 2 s.c om
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPage.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root, 879, 599);
        stage.setScene(scene);

        stage.setTitle("Main menu");
        stage.show();

    } catch (Exception ex) {
        Logger.getLogger(MainPageController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:aajavafx.VisitorController.java

@FXML
private void handleImageButton(ActionEvent event) {
    Node node = (Node) event.getSource();
    Stage stage = (Stage) node.getScene().getWindow();
    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser);//from   w w w . ja  v  a2s. c  o  m
    fileChooser.setTitle("Open Resource File");
    imageFile = fileChooser.showOpenDialog(stage);
    if (imageFile != null) {
        try {
            System.out.println("abs path: " + imageFile.getAbsolutePath());
            System.out.println("can oath: " + imageFile.getCanonicalPath());
            FileInputStream fis = new FileInputStream(imageFile.getCanonicalPath());
            Image image = new Image(fis);
            imageView.setImage(image);
        } catch (IOException ie) {
            System.out.println("IO Error: " + ie);
        }
    }

    /*if(file != null) {
    openFile(file);
            
    }*/

}

From source file:aajavafx.VisitorController.java

@FXML
private void handleGoBack(ActionEvent event) {
    try {//from ww  w  . j  ava  2  s  . c  om
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPage.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root, 879, 599);
        stage.setScene(scene);

        stage.setTitle("Main menu");
        stage.show();

    } catch (Exception ex) {
        Logger.getLogger(MainPageController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:aajavafx.CustomerMedicineController.java

@FXML
private void handleBackButton(ActionEvent event) {
    try {//from  w w  w  . j av a  2 s  .  co  m

        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();

        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainPageTab.fxml"));
        Parent root = loader.load();

        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();

        System.out.println("You clicked Schedule!");
    } catch (Exception ex) {

        System.out.println("ERROR! " + ex);
    }
}