public void start(Stage stage) { Scene scene = new Scene(new Group(), 300, 200); stage.setScene(scene); stage.titleProperty().bind( scene.widthProperty().asString(). concat(" : "). concat(scene.heightProperty().asString())); stage.show(); }
); myPopupStage.titleProperty().bind(this.titleProperty()); binding = binding.and( () -> myPopupStage.titleProperty().unbind() );
text.setFill(Color.WHITE); title.bind(primaryStage.titleProperty()); //binds title to the primaryStage's title
public class MyWindow extends Stage { public static final String APP_NAME = "My App"; public void setupStage(Stage stage) { stage.initStyle(StageStyle.UNIFIED); stage.titleProperty().addListener((observable, oldTitle, newTitle) -> { if(newTitle == null || newTitle.isEmpty()) { setTitle(APP_NAME); } else if(!newTitle.equals(oldTitle + "-" + APP_NAME) && !newTitle.equals(APP_NAME)) { setTitle(newTitle + "-" + APP_NAME); } }); } public MyWindow() { super(); setupStage(this); } }
public class DoHugeChoiceBox extends Application { @Override public void start(Stage stage) { ObservableList<String> list = FXCollections.<String>observableArrayList(); for (int i = 0; i < 2000; i++) { list.add("item " + i); } ChoiceBox cb = new ChoiceBox(list); cb.getSelectionModel().select(1000); HBox g = HBoxBuilder.create().children(cb).build(); stage.titleProperty().bind(cb.valueProperty()); stage.setScene(new Scene(g)); stage.setHeight(100); stage.setWidth(200); stage.show(); } public static void main(String[] args) { launch(); } }
public class MyApp extends Application { private static final String APP_NAME = "My App "; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { TextField titleTextField = new TextField(); GridPane grid = new GridPane(); grid.add(titleTextField, 1, 1); Scene scene = new Scene(grid, 300, 275); primaryStage.setScene(scene); primaryStage.titleProperty().bind(Bindings.concat(APP_NAME).concat(titleTextField.textProperty())); primaryStage.show(); } }
primaryStage.titleProperty().bind(new SimpleStringProperty("Copper Monitor (server: ").concat(applicationContext.serverAddressProperty().concat(")"))); new Button(); // Trigger loading of default stylesheet final Scene scene = new Scene(applicationContext.getMainPane(), 1280, 800);
public static void bindToStageTitle(Node n, StringProperty property) { ChangeListener<Window> windowListener = (observable, oldValue, newValue) -> { if (oldValue != null && oldValue instanceof Stage) { ((Stage) oldValue).titleProperty().unbindBidirectional(property); } if (newValue != null && newValue instanceof Stage) { ((Stage) newValue).titleProperty().bindBidirectional(property); } }; n.sceneProperty().addListener((observable, oldValue, newValue) -> { if (oldValue != null) { oldValue.windowProperty().removeListener(windowListener); } if (newValue != null) { newValue.windowProperty().addListener(windowListener); if (newValue.getWindow() != null && newValue.getWindow() instanceof Stage) { ((Stage) newValue.getWindow()).titleProperty().bindBidirectional(property); } } }); if (n.getScene() != null) { n.getScene().windowProperty().addListener(windowListener); } }
stage.setScene(new Scene(handler.start(new DefaultFlowContainer()))); handler.getCurrentViewMetadata().addListener((e) -> { stage.titleProperty().unbind(); ViewMetadata metadata = handler.getCurrentViewMetadata().get(); if (metadata != null) { stage.titleProperty().bind(metadata.titleProperty()); stage.titleProperty().unbind(); ViewMetadata metadata = handler.getCurrentViewMetadata().get(); if (metadata != null) { stage.titleProperty().bind(metadata.titleProperty());
text.setFill(Color.WHITE); title.bind(primaryStage.titleProperty()); //binds title to the primaryStage's title