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:calendarioSeries.vistas.MainViewController.java

@FXML
private void handleButtonPressed(ActionEvent event) {
    Button buttonClicked = (Button) event.getSource();
    String id = buttonClicked.getId();
    for (Label diasMe : diasMes) {
        diasMe.setText("");
    }//  w w w .j a  v a  2 s  . co  m

    if (id.equals("next")) {
        if (mesActual.getNumMes() != 11) {
            mesActual = new Mes(mesActual.getNumAno(), mesActual.getNumMes() + 1);
        } else {
            mesActual = new Mes(mesActual.getNumAno() + 1, 0);
        }
    } else if (id.equals("previous")) {
        if (mesActual.getNumMes() != 0) {
            mesActual = new Mes(mesActual.getNumAno(), mesActual.getNumMes() - 1);
        } else {
            mesActual = new Mes(mesActual.getNumAno() - 1, 11);
        }
    }
    showDetallesMes(mesActual);
    event.consume();
}

From source file:com.bekwam.resignator.JarsignerConfigController.java

@FXML
public void close(ActionEvent evt) {
    if (logger.isDebugEnabled()) {
        logger.debug("[CLOSE]");
    }//from w  w  w . j a  v  a 2s. co m
    Scene scene = ((Button) evt.getSource()).getScene();
    if (scene != null) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }

}

From source file:aajavafx.Schedule1Controller.java

@FXML
private void handleGoBack(ActionEvent event) {

    try {//  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("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:com.exalttech.trex.ui.controllers.PacketBuilderHomeController.java

/**
 * Save button click handler/*from   w w w  .j av a  2s.  c o  m*/
 *
 * @param event
 */
@FXML
public void saveProfileBtnClicked(ActionEvent event) {
    if (saveStream()) {
        // close the dialog
        Node node = (Node) event.getSource();
        Stage stage = (Stage) node.getScene().getWindow();
        stage.hide();
    }
}

From source file:com.exalttech.trex.ui.controllers.PacketBuilderHomeController.java

/**
 * Load Pcap button click handler// w  ww .j  a v a 2s  .  co  m
 *
 * @param event
 * @throws Exception
 */
public void loadPcapFired(ActionEvent event) throws Exception {
    String loadLocation = PreferencesManager.getInstance().getLoadLocation();
    Window owner = ((Button) (event.getSource())).getScene().getWindow();
    File selectedFile = FileManager.getSelectedFile("Open Pcap File", "", owner, FileType.PCAP, loadLocation,
            false);

    if (selectedFile != null) {
        packetInfo = new PacketInfo();
        parser.parseFile(selectedFile.getAbsolutePath(), packetInfo);
        packetHex.setData(packetInfo);
        String encodedPcapFile = trafficProfile.encodePcapFile(selectedFile.getAbsolutePath());
        selectedProfile.getStream().getPacket().setBinary(encodedPcapFile);

    } else {
        LOG.info("file = null");
    }
}

From source file:aajavafx.CustomerController.java

@FXML
private void handleGoBack(ActionEvent event) {
    //labelError.setText(null);
    try {//  w ww.  j  a  va 2 s.  c  o  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, 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:org.noroomattheinn.visibletesla.OverviewController.java

@FXML
void panoButtonHandler(ActionEvent event) {
    Button source = (Button) event.getSource();
    final PanoCommand cmd = source == ventPanoButton ? PanoCommand.vent
            : ((source == openPanoButton) ? PanoCommand.open : PanoCommand.close);
    issueCommand(new Callable<Result>() {
        @Override//from   w  w  w  .ja  v  a  2s . co  m
        public Result call() {
            Result r = vtVehicle.getVehicle().setPano(cmd);
            updateStateLater(Vehicle.StateType.Vehicle, 5 * 1000);
            return r;
        }
    }, "Move Pano");
}

From source file:org.noroomattheinn.visibletesla.OverviewController.java

@FXML
void lockButtonHandler(ActionEvent event) {
    final Button source = (Button) event.getSource();
    issueCommand(new Callable<Result>() {
        @Override/*from  w ww.j a v  a 2s  . c  om*/
        public Result call() {
            Result r = vtVehicle.getVehicle().setLockState(source == lockButton);
            updateStateLater(Vehicle.StateType.Vehicle, 3 * 1000);
            return r;
        }
    }, (source == lockButton) ? "Lock" : "Unlock");
}

From source file:calendarioSeries.vistas.MainViewController.java

public void populateImagenes() {
    Platform.runLater(new Runnable() {
        @Override//ww  w.j  a  v a2 s . co  m
        public void run() {
            imagenes.getChildren().clear();
            for (Serie serie : series) {
                //System.out.println(serie.getLastVisto());
                try {
                    Image image = new Image(serie.getUrlImagen());
                    ImageView poster = new ImageView();
                    ContextMenu menu = new ContextMenu();
                    //String css = MainApp.class.getResource("resources/MainTheme.css").toExternalForm();
                    MenuItem delete = new MenuItem("Eliminar");
                    delete.setId(serie.getId());
                    delete.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent event) {
                            menu.hide();
                            MenuItem clicked = (MenuItem) event.getSource();
                            String toDelete = clicked.getId();
                            for (Serie serie : series) {
                                if (serie.getId().equals(toDelete)) {
                                    series.remove(serie);
                                    populateImagenes();
                                    showDetallesMes(mesActual);
                                }
                            }
                            event.consume();
                        }
                    });

                    menu.getItems().add(delete);

                    poster.setId(serie.getTitulo());
                    poster.setImage(image);
                    poster.setCache(true);
                    // poster.setPreserveRatio(true);
                    poster.setFitWidth(210);
                    poster.setFitHeight(300);
                    poster.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
                        @Override
                        public void handle(ContextMenuEvent event) {
                            menu.show(poster, event.getScreenX(), event.getScreenY());
                            //menu.getScene().getRoot().getStylesheets().add(css);
                            event.consume();
                        }
                    });
                    poster.setOnMouseClicked(new EventHandler<MouseEvent>() {
                        @Override
                        public void handle(MouseEvent event) {
                            if (event.getButton() == MouseButton.PRIMARY) {
                                try {
                                    //serieToPass = serie;
                                    sceneToPass = mainApp.scene;

                                    FXMLLoader loader = new FXMLLoader(
                                            getClass().getResource("DetailsSerieController.fxml"));
                                    Parent root = loader.load();
                                    DetailsSerieController controller = loader.getController();
                                    controller.setData(serie, series);
                                    controller.setMainApp(mainApp);

                                    Scene scene = new Scene(root);
                                    mainApp.primaryStage.setScene(scene);
                                    mainApp.primaryStage.show();
                                } catch (IOException ex) {
                                    ex.printStackTrace();
                                }
                            }
                        }

                    });
                    imagenes.getChildren().add(poster);
                } catch (IllegalArgumentException e) {
                    Image image = new Image("file:src/calendarioSeries/resources/no-image.png");
                    ImageView poster = new ImageView();
                    ContextMenu menu = new ContextMenu();
                    MenuItem delete = new MenuItem("Eliminar");
                    delete.setId(serie.getId());
                    delete.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent event) {
                            menu.hide();
                            MenuItem clicked = (MenuItem) event.getSource();
                            String toDelete = clicked.getId();
                            for (Serie serie : series) {
                                if (serie.getId().equals(toDelete)) {
                                    series.remove(serie);
                                    populateImagenes();
                                    showDetallesMes(mesActual);
                                }
                            }
                            event.consume();
                        }
                    });

                    menu.getItems().add(delete);

                    poster.setId(serie.getTitulo());
                    poster.setImage(image);
                    poster.setCache(true);
                    //poster.setPreserveRatio(true);
                    poster.setFitWidth(210);
                    poster.setFitHeight(300);
                    poster.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
                        @Override
                        public void handle(ContextMenuEvent event) {
                            menu.show(poster, event.getScreenX(), event.getScreenY());
                            event.consume();
                        }
                    });
                    Text text = new Text(serie.getTitulo());
                    text.getStyleClass().add("label");
                    StackPane pane = new StackPane();
                    pane.getChildren().addAll(poster, text);

                    imagenes.getChildren().add(pane);
                } finally {
                    rellenarArchivo();
                }
            }
        }
    });

}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXScopePickerPane.java

public CFBamJavaFXScopePickerPane(ICFFormManager formManager, ICFBamJavaFXSchema argSchema,
        ICFBamScopeObj argFocus, ICFLibAnyObj argContainer, Collection<ICFBamScopeObj> argDataCollection,
        ICFBamJavaFXScopeChosen whenChosen) {
    super();//  w w  w. jav  a 2 s .c o  m
    final String S_ProcName = "construct-schema-focus";
    if (formManager == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "formManager");
    }
    cfFormManager = formManager;
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 2,
                "argSchema");
    }
    if (whenChosen == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 6,
                "whenChosen");
    }
    invokeWhenChosen = whenChosen;
    // argFocus is optional; focus may be set later during execution as
    // conditions of the runtime change.
    javafxSchema = argSchema;
    javaFXFocus = argFocus;
    javafxContainer = argContainer;
    setJavaFXDataCollection(argDataCollection);
    dataTable = new TableView<ICFBamScopeObj>();
    tableColumnObjKind = new TableColumn<ICFBamScopeObj, String>("Class Code");
    tableColumnObjKind.setCellValueFactory(
            new Callback<CellDataFeatures<ICFBamScopeObj, String>, ObservableValue<String>>() {
                @Override
                public ObservableValue<String> call(CellDataFeatures<ICFBamScopeObj, String> p) {
                    ICFBamScopeObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        String classCode = obj.getClassCode();
                        ReadOnlyObjectWrapper<String> observable = new ReadOnlyObjectWrapper<String>();
                        observable.setValue(classCode);
                        return (observable);
                    }
                }
            });
    tableColumnObjKind.setCellFactory(
            new Callback<TableColumn<ICFBamScopeObj, String>, TableCell<ICFBamScopeObj, String>>() {
                @Override
                public TableCell<ICFBamScopeObj, String> call(TableColumn<ICFBamScopeObj, String> arg) {
                    return new CFStringTableCell<ICFBamScopeObj>();
                }
            });
    dataTable.getColumns().add(tableColumnObjKind);
    tableColumnId = new TableColumn<ICFBamScopeObj, Long>("Id");
    tableColumnId
            .setCellValueFactory(new Callback<CellDataFeatures<ICFBamScopeObj, Long>, ObservableValue<Long>>() {
                public ObservableValue<Long> call(CellDataFeatures<ICFBamScopeObj, Long> p) {
                    ICFBamScopeObj obj = p.getValue();
                    if (obj == null) {
                        return (null);
                    } else {
                        long value = obj.getRequiredId();
                        Long wrapped = new Long(value);
                        ReadOnlyObjectWrapper<Long> observable = new ReadOnlyObjectWrapper<Long>();
                        observable.setValue(wrapped);
                        return (observable);
                    }
                }
            });
    tableColumnId
            .setCellFactory(new Callback<TableColumn<ICFBamScopeObj, Long>, TableCell<ICFBamScopeObj, Long>>() {
                @Override
                public TableCell<ICFBamScopeObj, Long> call(TableColumn<ICFBamScopeObj, Long> arg) {
                    return new CFInt64TableCell<ICFBamScopeObj>();
                }
            });
    dataTable.getColumns().add(tableColumnId);
    dataTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ICFBamScopeObj>() {
        @Override
        public void changed(ObservableValue<? extends ICFBamScopeObj> observable, ICFBamScopeObj oldValue,
                ICFBamScopeObj newValue) {
            setJavaFXFocus(newValue);
            if (buttonChooseSelected != null) {
                if (newValue != null) {
                    buttonChooseSelected.setDisable(false);
                } else {
                    buttonChooseSelected.setDisable(true);
                }
            }
        }
    });
    hboxMenu = new CFHBox(10);
    buttonCancel = new CFButton();
    buttonCancel.setMinWidth(200);
    buttonCancel.setText("Cancel");
    buttonCancel.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            final String S_ProcName = "handle";
            try {
                cfFormManager.closeCurrentForm();
            } catch (Throwable t) {
                CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t);
            }
        }
    });
    hboxMenu.getChildren().add(buttonCancel);
    buttonChooseNone = new CFButton();
    buttonChooseNone.setMinWidth(200);
    buttonChooseNone.setText("ChooseNone");
    buttonChooseNone.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            final String S_ProcName = "handle";
            try {
                ICFBamSchemaObj schemaObj = (ICFBamSchemaObj) javafxSchema.getSchema();
                if (schemaObj == null) {
                    throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                            "schemaObj");
                }
                invokeWhenChosen.choseScope(null);
                cfFormManager.closeCurrentForm();
            } catch (Throwable t) {
                CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t);
            }
        }
    });
    hboxMenu.getChildren().add(buttonChooseNone);
    buttonChooseSelected = new CFButton();
    buttonChooseSelected.setMinWidth(200);
    buttonChooseSelected.setText("ChooseSelected");
    buttonChooseSelected.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            final String S_ProcName = "handle";
            try {
                ICFBamSchemaObj schemaObj = (ICFBamSchemaObj) javafxSchema.getSchema();
                if (schemaObj == null) {
                    throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                            "schemaObj");
                }
                ICFBamScopeObj selectedInstance = getJavaFXFocusAsScope();
                invokeWhenChosen.choseScope(selectedInstance);
                cfFormManager.closeCurrentForm();
            } catch (Throwable t) {
                CFConsole.formException(S_FormName, ((CFButton) e.getSource()).getText(), t);
            }
        }
    });
    hboxMenu.getChildren().add(buttonChooseSelected);
    if (argFocus != null) {
        dataTable.getSelectionModel().select(argFocus);
    }
    setTop(hboxMenu);
    setCenter(dataTable);
}