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); }
private static void apply(Brand brand, InfoComponent info, Stage stage, Scene scene) { if (stage != null) { stage.setTitle(info.getTitle()); } brand.logoSmall() .map(Image::new) .ifPresent(icon -> { if (stage != null) { stage.getIcons().add(icon); } @SuppressWarnings("unchecked") final Stage dialogStage = (Stage) scene.getWindow(); if (dialogStage != null) { dialogStage.getIcons().add(icon); } }); brand.stylesheets().forEachOrdered(scene.getStylesheets()::add); }
public static void applyBrandToStage(Injector injector, Stage stage) { final InfoComponent info = injector.getOrThrow(InfoComponent.class); final Brand brand = injector.getOrThrow(Brand.class); stage.setTitle(info.getTitle()); brand.logoSmall() .map(Image::new) .ifPresent(stage.getIcons()::add); }
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class StackoverflowIcon extends Application { @Override public void start(Stage stage) { StackPane root = new StackPane(); // set icon stage.getIcons().add(new Image("/path/to/stackoverflow.jpg")); stage.setTitle("Wow!! Stackoverflow Icon"); stage.setScene(new Scene(root, 300, 250)); stage.show(); } public static void main(String[] args) { launch(args); } }
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class StackoverflowIcon extends Application { @Override public void start(Stage stage) { StackPane root = new StackPane(); // set icon stage.getIcons().add(new Image("/path/to/stackoverflow.jpg")); stage.setTitle("Wow!! Stackoverflow Icon"); stage.setScene(new Scene(root, 300, 250)); stage.show(); } public static void main(String[] args) { launch(args); } }
@Override public Parent loadAsModal(String name) { final Stage mainStage = requireNonNull(userInterfaceComponent.getStage()); final Stage dialog = new Stage(); final Parent root = (Parent) load(name); final Scene scene = new Scene(root); BrandUtil.applyBrandToScene(injector, scene); dialog.setTitle("About " + infoComponent.getTitle()); dialog.initModality(APPLICATION_MODAL); brand.logoSmall().map(Image::new).ifPresent(dialog.getIcons()::add); dialog.initOwner(mainStage); dialog.setScene(scene); dialog.show(); return root; } }
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow(); stage.getIcons().add( new Image(this.getClass().getResource("<image>.png").toString()));
dialog.setHeaderText("Header message"); Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow(); stage.getIcons().add(new Image(this.getClass().getResource("<image>.png").toString())); service.start(); });
@Override public void start(final Stage stage) { stage.getIcons().add(new Image("icon.png")); }
ChoiceDialog<String> dialog = new ChoiceDialog<>(currentFullscreenSetting, choices); dialog.setTitle("Settings"); dialog.setHeaderText("Settings"); dialog.setContentText("Fullscreen on startup: "); dialog.setGraphic(new ImageView(this.getClass().getResource("img/settings.png").toString())); Stage stage2 = (Stage) dialog.getDialogPane().getScene().getWindow(); stage2.getIcons().add(new Image(this.getClass().getResource("img/settings.png").toString())); // Traditional way to get the response value. Optional<String> result = dialog.showAndWait();
@Override public void start(Stage primaryStage) { this.primaryStage = primaryStage; injector = initInjector(); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionLogger()); initSejda(); cleanIfRequired(); primaryStage.setScene(initScene()); primaryStage.getIcons().addAll(injector.instancesOfType(Image.class)); primaryStage.setTitle(injector.instance(Pdfsam.class).name()); primaryStage.setOnCloseRequest(e -> Platform.exit()); requestPremiumModulesDescriptionIfRequired(); initWindowsStatusController(primaryStage); initDialogsOwner(primaryStage); initActiveModule(); loadWorkspaceIfRequired(); initOpenButtons(); primaryStage.show(); requestCheckForUpdateIfRequired(); requestLatestNewsIfRequired(); eventStudio().addAnnotatedListeners(this); closeSplash(); STOPWATCH.stop(); LOG.info(DefaultI18nContext.getInstance().i18n("Started in {0}", DurationFormatUtils.formatDurationWords(STOPWATCH.getTime(), true, true))); new InputPdfArgumentsController().accept(rawParameters); }
@Override public void run() { primary.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("img/main/dmx-icon-16x16.png"))); primary.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("img/main/dmx-icon-32x32.png"))); primary.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("img/main/dmx-icon-64x64.png"))); // make containers for menu and toolbars VBox topContainer = new VBox(); topContainer.getChildren().addAll(menuBar, toolbarContainer); BorderPane bp = (BorderPane) primary.getScene().getRoot(); bp.setTop(topContainer); } });
public class MainApp extends Application { @Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml")); Scene scene = new Scene(root); stage.getIcons().add(new Image(this.getClass().getResourceAsStream("/images/so-icon.png"))); stage.setTitle("Icon Example"); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }
@FXML void handleHelpButton(ActionEvent event){ Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Help"); alert.setHeaderText("Help"); alert.setGraphic(new ImageView(this.getClass().getResource("img/help.png").toString())); alert.setContentText("Place the cursor over a button for hint."); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.getIcons().add(new Image(this.getClass().getResource("img/help.png").toString())); alert.showAndWait(); }
@Override public void start(Stage primaryStage) { primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("views/common/phoenicis.png"))); primaryStage.setTitle("Phoenicis"); loadFonts(); ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext( AppConfiguration.class); final MainController mainController = applicationContext.getBean(MainController.class); mainController.show(); mainController.setOnClose(() -> { applicationContext.getBean(ControlledThreadPoolExecutorServiceCloser.class).setCloseImmediately(true); applicationContext.close(); }); }
public class Test extends Application { @Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("DashBoard.fxml")); stage.getIcons().add(new Image("/com/images/icon.png")); Scene scene = new Scene(root); stage.setTitle("Dash Board"); stage.setMaximized(true); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args);
public class Main extends Application { @Override public void start(Stage stage) throws Exception { stage.getIcons().add(new Image(Main.class.getClassLoader().getResource("sample/icon.png").toExternalForm())); stage.setScene(new Scene(new Group(), 300, 275)); stage.show(); } public static void main(String[] args) {launch(args);} }
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); }
/** * Customize the primary Stage. */ private void initializeStage() { // Define the stage title this.stage.setTitle(applicationTitle()); // Define stage icons, the toolkit will use the best size final List<Image> stageIcons = stageIcons(); if (stageIcons != null && !stageIcons.isEmpty()) { this.stage.getIcons().addAll(stageIcons); } // and allow customization customizeStage(this.stage); }
@Override public void start(Stage stage) throws Exception { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("browser.fxml")); Parent root = (Parent) fxmlLoader.load(); stage.getIcons().addAll( new Image("/webfx/browser/icons/globe_16.png", 16, 16, true, true), new Image("webfx/browser/icons/globe_32.png", 32, 32, true, true), new Image("webfx/browser/icons/globe_64.png", 64, 64, true, true) ); BrowserFXController controller = fxmlLoader.getController(); controller.setLocale(getCurrentLocale()); Scene scene = new Scene(root); BrowserShortcuts shortcuts = new BrowserShortcuts(scene); shortcuts.setup(controller); stage.setTitle("WebFX Browser"); stage.setScene(scene); stage.show(); }