final Stage stage = new Stage(StageStyle.TRANSPARENT); Group rootGroup = new Group(); Scene scene = new Scene(rootGroup, 339, 319, Color.TRANSPARENT); stage.setScene(scene); stage.centerOnScreen(); stage.show();
public static void main(String[] args) { launch(args); } @Override public void start(final Stage primaryStage) { BorderPane pane = null; try { pane = (BorderPane) FXMLLoader.load(MAIN.class.getResource("FILE.fxml")); pane.getStyleClass().add("main"); } catch (IOException ex) { Logger.getLogger(MAIN.class.getName()).log(Level.SEVERE, null, ex); System.exit(-1); } primaryStage.setScene(new Scene(pane, 1100, 620)); primaryStage.getScene().getStylesheets().add(MAIN.class.getResource("FILE.css").toExternalForm()); primaryStage.centerOnScreen(); primaryStage.setTitle("Title"); primaryStage.show(); }
@Override public void start(final Stage stage) throws Exception { StackPane root = FXMLLoader.load(getClass().getResource("stage.fxml")); final Scene scene = new Scene(root); scene.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { System.out.println("width: "+number+" -> "+number2); } }); boolean resizable = true; stage.setResizable(resizable); stage.setTitle("Stage Resizable "+ resizable); stage.setScene(scene); stage.centerOnScreen(); stage.show(); }
// If Outer most AnchorPane pref size is fixed then use it in this event // Else otherwise use the handleWindowShownEvent(WindowEvent event) public void handleWindowShowingEvent(WindowEvent event) { Stage stage = (Stage) event.getSource(); // Get X Y of start-up location on Active Screen StartUpLocation startUpLoc = new StartUpLocation(mainWindowAnchorPane.getPrefWidth(), mainWindowAnchorPane.getPrefHeight()); double xPos = startUpLoc.getXPos(); double yPos = startUpLoc.getYPos(); // Set Only if X and Y are not zero and were computed correctly if (xPos != 0 && yPos != 0) { stage.setX(xPos); stage.setY(yPos); } else { stage.centerOnScreen(); } }
@Before public void before() { Node node = generateComponentToTest(); Parent parent = StackPaneBuilder.create().children(node).build(); Scene scene = SceneBuilder.create().root(parent).build(); if (this.currentStage != null) { this.currentStage.close(); } Stage stage = new Stage(); stage.setScene(scene); stage.centerOnScreen(); stage.show(); this.currentStage = stage; }
primaryStage.centerOnScreen(); primaryStage.show();
dialog.centerOnScreen(); } catch (Exception e) { LOG.error(e, e);
public void start(final Stage primaryStage) throws Exception { primaryStage.centerOnScreen(); primaryStage.setHeight(200); primaryStage.setWidth(300);
/** * {@inheritDoc} */ @Override public void start(final Stage stage) throws Exception { // Store the preloader stage to reuse it later this.preloaderStage = stage; // Configure the stage stage.centerOnScreen(); stage.initStyle(StageStyle.TRANSPARENT); stage.setScene(createPreloaderScene()); // Let's start the show stage.show(); }
/** * {@inheritDoc} */ @Override public void start(final Stage stage) throws Exception { // Store the preloader stage to reuse it later this.preloaderStage = stage; // Configure the stage stage.centerOnScreen(); stage.initStyle(StageStyle.TRANSPARENT); stage.setScene(createPreloaderScene()); // Let's start the show stage.show(); }
@Override public void start(Stage primaryStage) { Button btn = new Button("Resize"); btn.setOnAction((ActionEvent event) -> { changeStageSize(primaryStage, 800, 500); primaryStage.centerOnScreen(); }); StackPane root = new StackPane(btn); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.show(); } public void changeStageSize(Window stage, int width, int height) { stage.setWidth(width); stage.setHeight(height); }
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class MainClass extends Application{ @Override public void start(Stage stage) throws Exception{ stage.setTitle("Hi"); StackPane layout = new StackPane(); layout.getStylesheets().add("mainClass.css"); layout.getStyleClass().add("main-class"); Scene scene = new Scene(layout, 600, 250); scene.getStylesheets().add( getClass().getResource("mainClass.css").toExternalForm() ); stage.setScene(scene); stage.setResizable(false); stage.centerOnScreen(); stage.show(); } public static void main(String[] args) { launch(args); } }
@Override public void placeWindow(int[] location, int[] editorLocation) { if (sketch.sketchFullScreen()) { PApplet.hideMenuBar(); return; } int wide = sketch.width; // stage.getWidth() is NaN here //int high = sketch.height; // stage.getHeight() if (location != null) { // a specific location was received from the Runner // (applet has been run more than once, user placed window) stage.setX(location[0]); stage.setY(location[1]); } else if (editorLocation != null) { int locationX = editorLocation[0] - 20; int locationY = editorLocation[1]; if (locationX - wide > 10) { // if it fits to the left of the window stage.setX(locationX - wide); stage.setY(locationY); } else { // doesn't fit stage.centerOnScreen(); } } else { // just center on screen stage.centerOnScreen(); } }
Scene s = new Scene(l, 100, 100); Stage s1 = new Stage(StageStyle.TRANSPARENT); s1.centerOnScreen(); s1.setScene(s); s1.initModality(Modality.NONE);
stage.centerOnScreen(); stage.show();
@Override public void handle(WebEvent<String> t) { final Stage dialogStage = new Stage(); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.initOwner(owner); ResourceBundle r = ResourceBundle.getBundle("org/netbeans/html/boot/fx/Bundle"); // NOI18N dialogStage.setTitle(r.getString("AlertTitle")); // NOI18N final Button button = new Button(r.getString("AlertCloseButton")); // NOI18N final Text text = new Text(t.getData()); VBox box = new VBox(); box.setAlignment(Pos.CENTER); box.setSpacing(10); box.setPadding(new Insets(10)); box.getChildren().addAll(text, button); dialogStage.setScene(new Scene(box)); button.setCancelButton(true); button.setOnAction(new CloseDialogHandler(dialogStage, null)); dialogStage.centerOnScreen(); dialogStage.showAndWait(); } });
pane.getChildren().addAll( line, c0, c1, c2, c3, t0, t1, t2, t3 ); primaryStage.setScene( new Scene( pane )); primaryStage.centerOnScreen(); primaryStage.setWidth ( 580 ); primaryStage.setHeight( 280 );
cancel.setCancelButton(true); cancel.setOnAction(new CloseDialogHandler(dialogStage, null)); dialogStage.centerOnScreen(); dialogStage.showAndWait(); return res[0];
cancel.setCancelButton(true); cancel.setOnAction(new CloseDialogHandler(dialogStage, null)); dialogStage.centerOnScreen(); dialogStage.showAndWait(); return res[0] ? line.getText() : null;
@Override public void handle(WebEvent<String> t) { final Stage dialogStage = new Stage(); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.setTitle("Warning"); final Button button = new Button("Close"); final Text text = new Text(t.getData()); VBox box = new VBox(); box.setAlignment(Pos.CENTER); box.setSpacing(10); box.setPadding(new Insets(10)); box.getChildren().addAll(text, button); dialogStage.setScene(new Scene(box)); button.setCancelButton(true); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { dialogStage.close(); } }); dialogStage.centerOnScreen(); dialogStage.showAndWait(); } });