Search in sources :

Example 1 with Stage

use of javafx.stage.Stage in project JFoenix by jfoenixadmin.

the class SVGLoaderController method init.

@PostConstruct
public void init() throws FlowException, VetoException, Exception {
    final Stage stage = (Stage) context.getRegisteredObject("Stage");
    glyphDetailViewer = new GlyphDetailViewer();
    detailsContainer.getChildren().add(glyphDetailViewer);
    ScrollPane scrollableGlyphs = allGlyphs();
    scrollableGlyphs.setStyle("-fx-background-insets: 0;");
    iconsContainer.getChildren().add(scrollableGlyphs);
    browseFont.setOnAction((action) -> {
        FileChooser fileChooser = new FileChooser();
        FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("SVG files (*.svg)", "*.svg");
        fileChooser.getExtensionFilters().add(extFilter);
        File file = fileChooser.showOpenDialog(stage);
        if (file != null) {
            SVGGlyphLoader.clear();
            try {
                SVGGlyphLoader.loadGlyphsFont(new FileInputStream(file), file.getName());
                ScrollPane newglyphs = allGlyphs();
                newglyphs.setStyle("-fx-background-insets: 0;");
                iconsContainer.getChildren().clear();
                iconsContainer.getChildren().add(newglyphs);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : FileChooser(javafx.stage.FileChooser) Stage(javafx.stage.Stage) File(java.io.File) FileInputStream(java.io.FileInputStream) FlowException(io.datafx.controller.flow.FlowException) IOException(java.io.IOException) VetoException(io.datafx.controller.util.VetoException) PostConstruct(javax.annotation.PostConstruct)

Example 2 with Stage

use of javafx.stage.Stage in project PayFile by mikehearn.

the class GuiUtils method runAlert.

public static void runAlert(BiConsumer<Stage, AlertWindowController> setup) {
    // JavaFX doesn't actually have a standard alert template. Instead the Scene Builder app will create FXML
    // files for an alert window for you, and then you customise it as you see fit. I guess it makes sense in
    // an odd sort of way.
    Stage dialogStage = new Stage();
    dialogStage.initModality(Modality.APPLICATION_MODAL);
    FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml"));
    Pane pane = evalUnchecked(() -> (Pane) loader.load());
    AlertWindowController controller = loader.getController();
    setup.accept(dialogStage, controller);
    dialogStage.setScene(new Scene(pane));
    dialogStage.showAndWait();
}
Also used : Stage(javafx.stage.Stage) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) Pane(javafx.scene.layout.Pane)

Example 3 with Stage

use of javafx.stage.Stage in project processing by processing.

the class PSurfaceFX method setIcon.

public void setIcon(PImage icon) {
    int w = icon.pixelWidth;
    int h = icon.pixelHeight;
    WritableImage im = new WritableImage(w, h);
    im.getPixelWriter().setPixels(0, 0, w, h, PixelFormat.getIntArgbInstance(), icon.pixels, 0, w);
    Stage stage = (Stage) canvas.getScene().getWindow();
    stage.getIcons().clear();
    stage.getIcons().add(im);
}
Also used : WritableImage(javafx.scene.image.WritableImage) Stage(javafx.stage.Stage)

Example 4 with Stage

use of javafx.stage.Stage in project azure-tools-for-java by Microsoft.

the class JobUtilsForEclipse method openBrowser.

private static void openBrowser(String url) throws Exception {
    Application application = new Application() {

        @Override
        public void start(Stage primaryStage) throws Exception {
            getHostServices().showDocument(url);
        }
    };
    application.start(null);
}
Also used : Stage(javafx.stage.Stage) Application(javafx.application.Application)

Example 5 with Stage

use of javafx.stage.Stage in project Retrospector by NonlinearFruit.

the class SearchTabController method initSearchTab.

private void initSearchTab() {
    searchEditMedia.setDisable(true);
    searchDeleteMedia.setDisable(true);
    // Table Double Click
    searchTable.setRowFactory(tv -> {
        TableRow<Media> row = new TableRow<>();
        row.setOnMouseClicked(event -> {
            if (event.getClickCount() == 2 && (!row.isEmpty())) {
                setMedia(row.getItem());
                setTab(TAB.MEDIA);
            }
        });
        return row;
    });
    // Table data setup
    searchTableData = DataManager.getMedia();
    FilteredList<Media> mediaFiltered = new FilteredList(searchTableData, x -> true);
    SortedList<Media> mediaSortable = new SortedList<>(mediaFiltered);
    searchTable.setItems(mediaSortable);
    mediaSortable.comparatorProperty().bind(searchTable.comparatorProperty());
    // Link to data properties
    searchTitleColumn.setCellValueFactory(new PropertyValueFactory<>("Title"));
    searchCreatorColumn.setCellValueFactory(new PropertyValueFactory<>("Creator"));
    searchSeasonColumn.setCellValueFactory(new PropertyValueFactory<>("SeasonId"));
    searchEpisodeColumn.setCellValueFactory(new PropertyValueFactory<>("EpisodeId"));
    searchCategoryColumn.setCellValueFactory(new PropertyValueFactory<>("Category"));
    // Values for special columns
    searchNumberColumn.setSortable(false);
    searchNumberColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper(1 + searchTable.getItems().indexOf(p.getValue())));
    searchReviewsColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, Integer>, ObservableValue<Integer>>() {

        @Override
        public ObservableValue<Integer> call(TableColumn.CellDataFeatures<Media, Integer> p) {
            return new ReadOnlyObjectWrapper(p.getValue().getReviews().size());
        }
    });
    searchMeanRColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, BigDecimal>, ObservableValue<BigDecimal>>() {

        @Override
        public ObservableValue<BigDecimal> call(TableColumn.CellDataFeatures<Media, BigDecimal> p) {
            return new ReadOnlyObjectWrapper(p.getValue().getAverageRating());
        }
    });
    searchCurrentRColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Media, BigDecimal>, ObservableValue<BigDecimal>>() {

        @Override
        public ObservableValue<BigDecimal> call(TableColumn.CellDataFeatures<Media, BigDecimal> p) {
            return new ReadOnlyObjectWrapper(p.getValue().getCurrentRating());
        }
    });
    // Comparators for string columns
    searchTitleColumn.setComparator(new NaturalOrderComparator());
    searchCreatorColumn.setComparator(new NaturalOrderComparator());
    searchSeasonColumn.setComparator(new NaturalOrderComparator());
    searchEpisodeColumn.setComparator(new NaturalOrderComparator());
    searchCategoryColumn.setComparator(new NaturalOrderComparator());
    searchTable.getSelectionModel().selectedItemProperty().addListener((observe, old, neo) -> {
        setMedia(neo);
    });
    searchBox.textProperty().addListener((observa, old, neo) -> {
        String query = neo;
        if (query == null || query.equals(""))
            mediaFiltered.setPredicate(x -> true);
        else {
            String[] queries = query.split(":");
            mediaFiltered.setPredicate(x -> QueryProcessor.isMatchForMedia(query, x));
        }
        updateStats();
    });
    // Buttons
    searchNewMedia.setOnAction(e -> {
        Media neo = new Media();
        neo.setId(DataManager.createDB(neo));
        setMedia(neo);
        setTab(TAB.MEDIA);
    });
    searchQuickEntry.setOnAction(e -> {
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("QuickEntry.fxml"));
            Parent root1 = (Parent) fxmlLoader.load();
            QuickEntryController qec = fxmlLoader.getController();
            qec.setup(currentTab);
            Stage stage = new Stage();
            stage.setTitle("Quick Entry");
            stage.setScene(new Scene(root1));
            stage.show();
        } catch (Exception ex) {
        }
    });
    searchStandardEntry.setOnAction(e -> {
        Media neo = new Media();
        neo.setId(DataManager.createDB(neo));
        setMedia(neo);
        setTab(TAB.MEDIA);
    });
    searchBackup.setOnAction(e -> DataManager.makeBackup());
    searchCheatsheet.setOnAction(e -> {
        new Cheatsheet().start(new Stage());
    });
    searchEditMedia.setOnAction(e -> {
        setTab(TAB.MEDIA);
    });
    searchDeleteMedia.setOnAction(e -> {
        if (new Alert(Alert.AlertType.WARNING, "Are you sure you want to delete this?", ButtonType.NO, ButtonType.YES).showAndWait().get().equals(ButtonType.YES)) {
            DataManager.deleteDB(getMedia());
            updateSearchTab();
        }
    });
    // Init stuff
    updateStats();
}
Also used : Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) URL(java.net.URL) ButtonType(javafx.scene.control.ButtonType) Factoid(retrospector.model.Factoid) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) Media(retrospector.model.Media) Application(javafx.application.Application) BigDecimal(java.math.BigDecimal) Parent(javafx.scene.Parent) ResourceBundle(java.util.ResourceBundle) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) FXMLLoader(javafx.fxml.FXMLLoader) QuickEntryController(retrospector.fxml.QuickEntryController) NaturalOrderComparator(retrospector.util.NaturalOrderComparator) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) SortedList(javafx.collections.transformation.SortedList) Alert(javafx.scene.control.Alert) ObjectProperty(javafx.beans.property.ObjectProperty) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Review(retrospector.model.Review) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) TableRow(javafx.scene.control.TableRow) FilteredList(javafx.collections.transformation.FilteredList) TAB(retrospector.fxml.CoreController.TAB) FXML(javafx.fxml.FXML) Text(javafx.scene.text.Text) List(java.util.List) Stage(javafx.stage.Stage) MenuButton(javafx.scene.control.MenuButton) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) DataManager(retrospector.model.DataManager) QuickEntryController(retrospector.fxml.QuickEntryController) Parent(javafx.scene.Parent) SortedList(javafx.collections.transformation.SortedList) ObservableValue(javafx.beans.value.ObservableValue) FXMLLoader(javafx.fxml.FXMLLoader) FilteredList(javafx.collections.transformation.FilteredList) Stage(javafx.stage.Stage) Media(retrospector.model.Media) Scene(javafx.scene.Scene) TableColumn(javafx.scene.control.TableColumn) BigDecimal(java.math.BigDecimal) NaturalOrderComparator(retrospector.util.NaturalOrderComparator) TableRow(javafx.scene.control.TableRow) Alert(javafx.scene.control.Alert) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper)

Aggregations

Stage (javafx.stage.Stage)121 Scene (javafx.scene.Scene)60 IOException (java.io.IOException)23 FXML (javafx.fxml.FXML)21 FXMLLoader (javafx.fxml.FXMLLoader)18 Parent (javafx.scene.Parent)17 Application (javafx.application.Application)14 Node (javafx.scene.Node)14 Button (javafx.scene.control.Button)14 KeyCode (javafx.scene.input.KeyCode)14 BorderPane (javafx.scene.layout.BorderPane)13 List (java.util.List)11 File (java.io.File)10 ArrayList (java.util.ArrayList)10 Label (javafx.scene.control.Label)10 ObservableList (javafx.collections.ObservableList)9 Insets (javafx.geometry.Insets)9 ActionEvent (javafx.event.ActionEvent)8 MouseEvent (javafx.scene.input.MouseEvent)8 HBox (javafx.scene.layout.HBox)7