Java Code Examples for javafx.stage.Stage#getIcons()

The following examples show how to use javafx.stage.Stage#getIcons() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Designer.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void setIcons(Stage primaryStage) {
    ObservableList<Image> icons = primaryStage.getIcons();
    final String dirPrefix = "icons/app/";
    List<String> imageNames = Arrays.asList("designer_logo.jpeg");

    // TODO make more icon sizes

    List<Image> images = imageNames.stream()
                                   .map(s -> dirPrefix + s)
                                   .map(s -> getClass().getResourceAsStream(s))
                                   .filter(Objects::nonNull)
                                   .map(Image::new)
                                   .collect(Collectors.toList());

    icons.addAll(images);
}
 
Example 2
Source File: EditorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
public EditorDialog() {
    this.showedTime = LocalTime.now();

    container = new VBox();
    container.setAlignment(CENTER);

    var editorConfig = EditorConfig.getInstance();
    var theme = editorConfig.getEnum(PREF_UI_THEME, PREF_DEFAULT_THEME);

    var scene = new Scene(container);
    var stylesheets = scene.getStylesheets();
    stylesheets.addAll(CSS_REGISTRY.getAvailableCssFiles());
    stylesheets.add(theme.getCssFile());

    createControls(container);

    dialog = new Stage();
    dialog.setTitle(getTitleText());
    dialog.initStyle(StageStyle.UTILITY);
    dialog.initModality(Modality.WINDOW_MODAL);
    dialog.setResizable(isResizable());
    dialog.setScene(scene);

    var fxStage = EditorUtil.getFxStage();
    var icons = dialog.getIcons();
    icons.addAll(fxStage.getIcons());

    configureSize(container);
}
 
Example 3
Source File: JfxApplication.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FxThread
public void start(@NotNull Stage stage) throws Exception {
    JfxApplication.instance = this;
    this.stage = stage;

    addWindow(stage);
    try {

        // initialize javaFX events in javaFX thread.
        ArrayFactory.asArray(ComboBoxBase.ON_SHOWN);

        var resourceManager = ResourceManager.getInstance();
        resourceManager.reload();

        var initializationManager = InitializationManager.getInstance();
        initializationManager.onBeforeCreateJavaFxContext();

        var pluginManager = PluginManager.getInstance();
        pluginManager.handlePlugins(editorPlugin -> editorPlugin.register(CssRegistry.getInstance()));

        LogView.getInstance();
        SvgImageLoaderFactory.install();
        ImageIO.read(getClass().getResourceAsStream("/ui/icons/test/test.jpg"));

        var icons = stage.getIcons();
        icons.add(new Image("/ui/icons/app/256x256.png"));
        icons.add(new Image("/ui/icons/app/128x128.png"));
        icons.add(new Image("/ui/icons/app/96x96.png"));
        icons.add(new Image("/ui/icons/app/64x64.png"));
        icons.add(new Image("/ui/icons/app/48x48.png"));
        icons.add(new Image("/ui/icons/app/32x32.png"));
        icons.add(new Image("/ui/icons/app/24x24.png"));
        icons.add(new Image("/ui/icons/app/16x16.png"));

        var config = EditorConfig.getInstance();

        stage.initStyle(StageStyle.DECORATED);
        stage.setMinHeight(600);
        stage.setMinWidth(800);
        stage.setWidth(config.getScreenWidth());
        stage.setHeight(config.getScreenHeight());
        stage.setMaximized(config.isMaximized());
        stage.setTitle(Config.TITLE);
        stage.show();


        if (!stage.isMaximized()) {
            stage.centerOnScreen();
        }

        stage.widthProperty().addListener((observable, oldValue, newValue) -> {
            if (stage.isMaximized()) return;
            config.setScreenWidth(newValue.intValue());
        });
        stage.heightProperty().addListener((observable, oldValue, newValue) -> {
            if (stage.isMaximized()) return;
            config.setScreenHeight(newValue.intValue());
        });

        stage.maximizedProperty()
                .addListener((observable, oldValue, newValue) -> config.setMaximized(newValue));

        buildScene();

    } catch (Throwable e) {
        LOGGER.error(this, e);
        throw e;
    }
}
 
Example 4
Source File: DialogUtilsTest.java    From PeerWasp with MIT License 4 votes vote down vote up
private ObservableList<Image> alertIcons(Alert dlg) {
	Stage stage = (Stage) dlg.getDialogPane().getScene().getWindow();
	ObservableList<Image> icons = stage.getIcons();
	return icons;
}