Search in sources :

Example 66 with ActionEvent

use of javafx.event.ActionEvent in project ETUmulator by kasirgalabs.

the class FileMenuController method openRecentFilesOnAction.

@FXML
private void openRecentFilesOnAction(ActionEvent event) {
    openRecentTab = (Menu) event.getSource();
    openRecentTab.getItems().clear();
    MenuItem menuItem;
    if (controlRecent) {
        for (int i = recentFiles.size() - 1; i >= 0; i--) {
            File file = recentFiles.get(i);
            menuItem = new MenuItem(recentFiles.get(i).getName());
            openRecentTab.getItems().add(menuItem);
            menuItem.setOnAction(new EventHandler<ActionEvent>() {

                public void handle(ActionEvent t) {
                    if (file != null) {
                        StringBuilder text = new StringBuilder(256);
                        try (BufferedReader bf = new BufferedReader(new FileReader(file))) {
                            String line;
                            while ((line = bf.readLine()) != null) {
                                text.append(line).append('\n');
                            }
                        } catch (Exception e) {
                            System.out.println(e.getMessage());
                        }
                        document.setText(text.toString());
                        document.setTargetFile(file);
                    }
                }
            });
        }
    }
    controlRecent = false;
}
Also used : ActionEvent(javafx.event.ActionEvent) BufferedReader(java.io.BufferedReader) MenuItem(javafx.scene.control.MenuItem) FileReader(java.io.FileReader) File(java.io.File) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) FXML(javafx.fxml.FXML)

Example 67 with ActionEvent

use of javafx.event.ActionEvent in project ETUmulator by kasirgalabs.

the class PopUp method createPopup.

/**
 *Creating Popup to show exceptions in new window.
 *
 *In implementation users cannot edit the popUp's TextArea.
 */
public void createPopup() {
    console.setEditable(false);
    Stage stage = new Stage();
    stage.setTitle("Exception(s)!");
    VBox box = new VBox();
    box.setPadding(new Insets(5));
    box.setAlignment(Pos.CENTER);
    Button btnClose = new Button();
    btnClose.setText("Close");
    btnClose.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            stage.close();
            console.clear();
        }
    });
    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {

        @Override
        public void handle(WindowEvent t) {
            stage.close();
            console.clear();
        }
    });
    Button btnClear = new Button();
    btnClear.setText("Clear");
    btnClear.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            console.clear();
        }
    });
    box.getChildren().add(console);
    box.getChildren().add(btnClose);
    box.getChildren().add(btnClear);
    Scene scene1 = new Scene(box, 500, 250);
    stage.setScene(scene1);
    stage.show();
}
Also used : Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) ActionEvent(javafx.event.ActionEvent) WindowEvent(javafx.stage.WindowEvent) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 68 with ActionEvent

use of javafx.event.ActionEvent in project SIMVA-SoS by SESoS.

the class ChartViewer method createContextMenu.

/**
 * Creates the context menu.
 *
 * @return The context menu.
 */
private ContextMenu createContextMenu() {
    final ContextMenu menu = new ContextMenu();
    Menu export = new Menu("Export As");
    MenuItem pngItem = new MenuItem("PNG...");
    pngItem.setOnAction((ActionEvent e) -> {
        handleExportToPNG();
    });
    export.getItems().add(pngItem);
    MenuItem jpegItem = new MenuItem("JPEG...");
    jpegItem.setOnAction((ActionEvent e) -> {
        handleExportToJPEG();
    });
    export.getItems().add(jpegItem);
    if (ExportUtils.isOrsonPDFAvailable()) {
        MenuItem pdfItem = new MenuItem("PDF...");
        pdfItem.setOnAction((ActionEvent e) -> {
            handleExportToPDF();
        });
        export.getItems().add(pdfItem);
    }
    if (ExportUtils.isJFreeSVGAvailable()) {
        MenuItem svgItem = new MenuItem("SVG...");
        svgItem.setOnAction((ActionEvent e) -> {
            handleExportToSVG();
        });
        export.getItems().add(svgItem);
    }
    menu.getItems().add(export);
    return menu;
}
Also used : ActionEvent(javafx.event.ActionEvent) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) Menu(javafx.scene.control.Menu) ContextMenu(javafx.scene.control.ContextMenu)

Example 69 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class SettingsController method unarchiveSource.

@FXML
private void unarchiveSource(ActionEvent event) {
    try {
        source.unarchiveSource(sourcecmboUnArchive.getValue());
        Alert confirmationMsg = new Alert(AlertType.INFORMATION);
        confirmationMsg.setTitle("Message");
        confirmationMsg.setHeaderText(null);
        confirmationMsg.setContentText(sourcecmboUnArchive.getValue() + " is Unarchived Successfully");
        Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
        confirmationMsg.setX(SettingsStage.getX() + 200);
        confirmationMsg.setY(SettingsStage.getY() + 170);
        Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                confirmationMsg.hide();
            }
        }));
        idlestage.setCycleCount(1);
        idlestage.play();
        confirmationMsg.showAndWait();
        tabSourceInitialize();
    } catch (Exception e) {
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Example 70 with ActionEvent

use of javafx.event.ActionEvent in project Money-Manager by krHasan.

the class SettingsController method systembtnSave.

@FXML
private void systembtnSave(ActionEvent event) {
    DateFormatManager format = new DateFormatManager();
    try {
        String timeFormat = (String) timerbtnGroup.getSelectedToggle().getUserData();
        String dateFormat = (String) daterbtnGroup.getSelectedToggle().getUserData();
        format.setTimeFormate(timeFormat);
        format.setDateFormate(dateFormat);
        updateLastAccessDate();
        if (checkBoxWeekNum.isSelected()) {
            setWeekStatus(true);
        } else {
            setWeekStatus(false);
        }
        Alert confirmationMsg = new Alert(AlertType.INFORMATION);
        confirmationMsg.setTitle("Message");
        confirmationMsg.setHeaderText(null);
        confirmationMsg.setContentText("Information updated successfully");
        Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
        confirmationMsg.setX(SettingsStage.getX() + 200);
        confirmationMsg.setY(SettingsStage.getY() + 170);
        Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(2), new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                confirmationMsg.hide();
            }
        }));
        idlestage.setCycleCount(1);
        idlestage.play();
        confirmationMsg.showAndWait();
        tabSystemInitialize();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) DateFormatManager(system.DateFormatManager) Stage(javafx.stage.Stage) KeyFrame(javafx.animation.KeyFrame) EventHandler(javafx.event.EventHandler) Alert(javafx.scene.control.Alert) FXML(javafx.fxml.FXML)

Aggregations

ActionEvent (javafx.event.ActionEvent)171 EventHandler (javafx.event.EventHandler)61 Stage (javafx.stage.Stage)52 KeyFrame (javafx.animation.KeyFrame)47 Timeline (javafx.animation.Timeline)47 FXML (javafx.fxml.FXML)44 Alert (javafx.scene.control.Alert)36 Button (javafx.scene.control.Button)35 Label (javafx.scene.control.Label)35 MenuItem (javafx.scene.control.MenuItem)33 ContextMenu (javafx.scene.control.ContextMenu)25 File (java.io.File)24 Insets (javafx.geometry.Insets)24 Scene (javafx.scene.Scene)24 List (java.util.List)21 ObservableList (javafx.collections.ObservableList)21 Node (javafx.scene.Node)20 TextField (javafx.scene.control.TextField)20 Optional (java.util.Optional)18 FXCollections (javafx.collections.FXCollections)18