Example usage for javafx.stage StageStyle UTILITY

List of usage examples for javafx.stage StageStyle UTILITY

Introduction

In this page you can find the example usage for javafx.stage StageStyle UTILITY.

Prototype

StageStyle UTILITY

To view the source code for javafx.stage StageStyle UTILITY.

Click Source Link

Document

Defines a Stage style with a solid white background and minimal platform decorations used for a utility window.

Usage

From source file:de.pixida.logtest.designer.commons.ExceptionDialog.java

public static void showFatalException(final String title, final String message, final Throwable exception) {
    final Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.initStyle(StageStyle.UTILITY);
    alert.setTitle("Error");
    alert.setHeaderText(title);/*from  w  w w .  j ava2 s. c  o m*/
    alert.setContentText(message);

    final Label label = new Label("Details:");

    final TextArea textArea = new TextArea(ExceptionUtils.getStackTrace(exception));
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    final GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);

    alert.showAndWait();
}

From source file:com.toyota.carservice.config.config2.java

public static void dialog(Alert.AlertType alertType, String s) {
    Alert alert = new Alert(alertType, s);
    alert.initStyle(StageStyle.UTILITY);
    alert.setTitle("Info");
    alert.showAndWait();/*from   w w w  .j  a v a2 s .co m*/
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.initStyle(StageStyle.UTILITY);
    Text text = new Text("!");
    text.setFont(new Font(40));
    VBox box = new VBox();
    box.getChildren().add(text);/*from   w  w  w .ja  va 2s  . c  o  m*/
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {

    Button openURLButton = new Button("Go!");
    openURLButton.setOnAction(e -> {/*from   ww w.j  a  v a  2  s  .c  om*/
        HostServices host = getHostServices();
        JSObject js = host.getWebContext();
        if (js == null) {
            Stage s = new Stage(StageStyle.UTILITY);
            s.initModality(Modality.WINDOW_MODAL);
            Label msgLabel = new Label("This is an FX alert!");
            Group root = new Group(msgLabel);
            Scene scene = new Scene(root);
            s.setScene(scene);
            s.setTitle("FX Alert");
            s.show();
        } else {
            js.eval("window.alert('This is a JavaScript alert!')");
        }
    });

    Scene scene = new Scene(openURLButton);
    stage.setScene(scene);
    stage.setTitle("Knowing the Host");
    stage.show();
}

From source file:org.pdfsam.ui.dialog.OverwriteConfirmationDialog.java

@Inject
public OverwriteConfirmationDialog(StylesConfig styles) {
    initModality(Modality.WINDOW_MODAL);
    initStyle(StageStyle.UTILITY);
    setResizable(false);// ww w  .  j av  a 2s. com
    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.getStyleClass().addAll("-pdfsam-dialog", "-pdfsam-warning-dialog");
    containerPane.setCenter(dialogContent);
    HBox buttons = new HBox(buildButton(DefaultI18nContext.getInstance().i18n("Overwrite"), true),
            buildButton(DefaultI18nContext.getInstance().i18n("Cancel"), false));
    buttons.getStyleClass().add("-pdfsam-dialog-buttons");
    containerPane.setBottom(buttons);
    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
}

From source file:de.serverfrog.pw.ui.MainViewController.java

@FXML
public void onLoadButton(ActionEvent ae) {
    try {//from  w w  w  .j a  v  a2s.c  om
        if (this.masterPasswordField.getText().isEmpty()) {
            return;
        }
        Stage dialog = new Stage(StageStyle.UTILITY);
        dialog.initModality(Modality.APPLICATION_MODAL);
        FXMLLoader fXMLLoader = new FXMLLoader(
                getClass().getResource("/de/serverfrog/pw/ui/ConfigLoadDialog.fxml"));
        Parent root = fXMLLoader.<Parent>load();
        ConfigLoadDialogController controller = fXMLLoader.<ConfigLoadDialogController>getController();
        try {
            controller.prepareList(masterPasswordField.getText());
        } catch (IOException exception) {
            this.messageField.setText(exception.getMessage());
            return;
        }
        this.messageField.setText("");
        Scene scene = new Scene(root);
        dialog.setScene(scene);
        controller.setStage(dialog);
        dialog.showAndWait();
        setConfiguration(controller.getConfig());
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ui.ChoseFonctionnalite.java

private void startClientMode(ActionEvent eventT) {
    //File config = new File("resource/config.json");
    String host = "";
    String port = "8000";
    Stage stageModal = new Stage();
    Pane root = new Pane();
    root.setBackground(new Background(new BackgroundImage(new Image("resource/background.jpg"),
            BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
            new BackgroundSize(530, 400, true, true, true, true))));
    stageModal.setScene(new Scene(root, 200, 200));
    stageModal.initStyle(StageStyle.UTILITY);
    Label adresse = new Label("Adresse serveur:");
    adresse.setLayoutX(10);/*from   w  w  w. j av a  2s  .  co  m*/
    adresse.setLayoutY(10);
    adresse.setFont(Font.font("Arial", 16));
    JFXTextField adresseInput = new JFXTextField("127.0.0.1");
    adresseInput.setPrefWidth(180);
    adresseInput.setLayoutX(10);
    adresseInput.setLayoutY(40);
    JFXButton valider = new JFXButton("Se connecter");
    valider.setCursor(Cursor.HAND);
    valider.setMinSize(100, 30);
    valider.setLayoutX(20);
    valider.setLayoutY(130);
    valider.setFont(new Font(20));
    valider.setStyle("-fx-background-color: #9E21FF;");
    valider.setOnAction(event -> {
        if (adresseInput.getText() != "") {
            stageModal.close();
            InitClient initializeClient = new InitClient(stage, adresseInput.getText(), port);
        }
    });
    root.getChildren().add(valider);
    root.getChildren().add(adresse);
    root.getChildren().add(adresseInput);
    stageModal.setTitle("Adresse serveur");
    stageModal.initModality(Modality.WINDOW_MODAL);
    stageModal.initOwner(((Node) eventT.getSource()).getScene().getWindow());
    stageModal.show();
}

From source file:org.virtualAsylum.spriggan.data.Addon.java

public State doInstall() {
    log("Installing %s (%s)", getDisplayName(), getID());
    State result = State.IDLE;
    State error = State.ERROR;
    setState(State.INSTALLING);/*from  w  w  w.  java2  s.  c om*/
    setStateProgress(-1);
    boolean didError = false;
    try {
        //<editor-fold desc="Dependencies">
        Collection<String> dependencyIDs = getDependencies();
        ArrayList<Addon> dependencies = new ArrayList();
        if (dependencyIDs.size() > 0) {
            setState(State.INSTALLING_DEPENDENCIES);
            for (String dependencyIDString : dependencyIDs) {
                Addon dependency = Database.find_ID(dependencyIDString);
                if (dependency == null) {
                    throw new Exception(String.format("Dependency %s was missing for %s(%s)",
                            dependencyIDString, getDisplayName(), getID()));
                }
                if (!dependency.getInstalled()) {
                    dependencies.add(dependency);
                }
            }
            if (dependencies.size() > 0) {
                SimpleObjectProperty<Boolean> popupResult = new SimpleObjectProperty(null);
                runLater(() -> {
                    DependencyPopup popup = new DependencyPopup(this, dependencies, popupResult);
                    Stage stage = popup.popup(StageStyle.UTILITY, Modality.WINDOW_MODAL,
                            MainInterface.current.getWindow(), getDisplayName());
                    stage.setOnCloseRequest(e -> popupResult.set(false));
                    stage.show();
                });

                while (popupResult.get() == null) {
                    sleep(500);
                }
                if (!popupResult.get()) {
                    error = State.IDLE;
                    throw new Exception(String.format("Did not install dependencies for %s (%s)",
                            getDisplayName(), getID()));
                }
                double perDep = 1.0 / dependencies.size();
                setStateProgress(0.0);
                for (Addon dependency : dependencies) {
                    boolean downloaded = Database.getCurrent().getRepository().contains(dependency);
                    State depResult = State.IDLE;
                    if (!downloaded) {
                        depResult = dependency.doDownloadAndInstall();
                    } else if (!dependency.getInstalled()) {
                        depResult = dependency.doInstall();
                    }
                    if (depResult != State.IDLE) {
                        throw new Exception(
                                String.format("Dependency %s (%s) failed to download and/or install",
                                        dependency.getDisplayName(), dependency.getID()));
                    }
                    incrementStateProgress(perDep);
                }
                setState(State.INSTALLING);
            }

        }
        //</editor-fold>

        error = State.ERROR;

        final File repositoryDirectory = getRepositoryDirectory(this);
        final File installDirectory = getInstallDirectory(this);

        ArrayList<File> files = getRepositoryFiles();

        double perFile = 1.0 / files.size();
        setStateProgress(0.0);
        for (File inputFile : files) {
            File outputFile = new File(installDirectory,
                    repositoryDirectory.toPath().relativize(inputFile.toPath()).toString());
            outputFile.getParentFile().mkdirs();
            Files.copy(inputFile.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
            incrementStateProgress(perFile);
        }

    } catch (Exception ex) {
        if (error == State.ERROR) {
            handleException(ex);
        }
        result = error;
        didError = true;
    }

    if (!didError) {
        setInstalled(true);
    }
    log("Installing %s (%s): %s", getDisplayName(), getID(), result);
    setStateProgress(0);
    setState(result);
    return result;
}

From source file:com.panemu.tiwulfx.control.LookupFieldController.java

/**
 * Show lookup dialog./*from  w  w w.  j  a va  2  s .  co  m*/
 *
 * @param stage parent
 * @param initialValue this value will be returned if user clik the close
 * button instead of double clicking a row or click Select button
 * @param propertyName propertyName corresponds to searchCriteria
 * @param searchCriteria searchCriteria (nullable)
 * @return selected object or the initialValue
 */
public T show(final Window stage, T initialValue, String propertyName, String searchCriteria) {
    if (dialogStage == null) {
        PropertyDescriptor[] props = PropertyUtils.getPropertyDescriptors(recordClass);
        lookupWindow = new LookupWindow();
        for (String clm : getColumns()) {
            for (PropertyDescriptor prop : props) {
                if (prop.getName().equals(clm)) {
                    Class type = prop.getPropertyType();
                    if (type.equals(Boolean.class)) {
                        lookupWindow.table.addColumn(new CheckBoxColumn<T>(clm));
                    } else if (type.equals(String.class)) {
                        lookupWindow.table.addColumn(new TextColumn<T>(clm));
                    } else if (type.equals(Date.class)) {
                        lookupWindow.table.addColumn(new LocalDateColumn<T>(clm));
                    } else if (Number.class.isAssignableFrom(type)) {

                        if (Long.class.isAssignableFrom(type)) {
                            lookupWindow.table.addColumn(new NumberColumn<T, Long>(clm, type));
                        } else {
                            lookupWindow.table.addColumn(new NumberColumn<T, Double>(clm, type));
                        }
                    } else {
                        TableColumn column = new TableColumn();
                        column.setCellValueFactory(new PropertyValueFactory(clm));
                        lookupWindow.table.addColumn(column);
                    }
                    break;
                }
            }

        }
        dialogStage = new Stage();
        if (stage instanceof Stage) {
            dialogStage.initOwner(stage);
            dialogStage.initModality(Modality.WINDOW_MODAL);
        } else {
            dialogStage.initOwner(null);
            dialogStage.initModality(Modality.APPLICATION_MODAL);
        }
        dialogStage.initStyle(StageStyle.UTILITY);
        dialogStage.setResizable(true);
        dialogStage.setScene(new Scene(lookupWindow));
        dialogStage.getIcons().add(new Image(
                LookupFieldController.class.getResourceAsStream("/com/panemu/tiwulfx/res/image/lookup.png")));
        dialogStage.setTitle(getWindowTitle());
        dialogStage.getScene().getStylesheets()
                .add(getClass().getResource("/com/panemu/tiwulfx/res/tiwulfx.css").toExternalForm());
        initCallback(lookupWindow, lookupWindow.table);
    }

    for (TableColumn column : lookupWindow.table.getTableView().getColumns()) {
        if (column instanceof BaseColumn && ((BaseColumn) column).getPropertyName().equals(propertyName)) {
            if (searchCriteria != null && !searchCriteria.isEmpty()) {
                TableCriteria tc = new TableCriteria(propertyName, TableCriteria.Operator.ilike_anywhere,
                        searchCriteria);
                ((BaseColumn) column).setTableCriteria(tc);
            } else {
                ((BaseColumn) column).setTableCriteria(null);
            }

            break;
        }
    }
    selectedValue = initialValue;
    beforeShowCallback(lookupWindow.table);
    lookupWindow.table.reloadFirstPage();

    if (stage != null) {
        /**
         * Since we support multiple monitors, ensure that the stage is
         * located in the center of parent stage. But we don't know the
         * dimension of the stage for the calculation, so we defer the
         * relocation after the stage is actually displayed.
         */
        Runnable runnable = new Runnable() {
            public void run() {
                dialogStage.setX(stage.getX() + stage.getWidth() / 2 - dialogStage.getWidth() / 2);
                dialogStage.setY(stage.getY() + stage.getHeight() / 2 - dialogStage.getHeight() / 2);

                //set the opacity back to fully opaque
                dialogStage.setOpacity(1);
            }
        };

        Platform.runLater(runnable);

        //set the opacity to 0 to minimize flicker effect
        dialogStage.setOpacity(0);
    }

    dialogStage.showAndWait();
    return selectedValue;
}

From source file:de.pixida.logtest.designer.MainWindow.java

private void createAndAppendHelpMenuItems(final Menu help) {
    final MenuItem visitDocumentation = new MenuItem("Visit Online Documentation");
    visitDocumentation.setGraphic(Icons.getIconGraphics("help"));
    visitDocumentation.setOnAction(event -> {
        Exception ex = null;/*from   w  w  w .j  av a  2  s . c om*/
        final String url = "https://github.com/Pixida/logtest/wiki";
        final Desktop desktop = java.awt.Desktop.getDesktop();
        if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
            try {
                desktop.browse(new URI(url));
            } catch (final Exception e) {
                ex = e;
            }
        } else {
            ex = new Exception("Browsing not supported.");
        }
        if (ex != null) {
            ExceptionDialog.showFatalException("Failed to open browser", "Visit us at " + url, ex);
        }
    });

    final MenuItem about = new MenuItem("About " + APP_TITLE);
    about.setGraphic(Icons.getIconGraphics(APP_ICON));
    about.setOnAction(event -> {
        final Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.initStyle(StageStyle.UTILITY);
        alert.setTitle(about.getText());
        alert.setHeaderText(APP_TITLE);
        alert.setContentText("Copyright (C) " + Calendar.getInstance().get(Calendar.YEAR) + " Pixida GmbH\n"
                + "\n" + "This application includes FAMFAMFAM icons (http://www.famfamfam.com).");
        alert.showAndWait();
    });

    help.getItems().addAll(visitDocumentation, about);
}