Refine search
public class CenterStage extends Application { @Override public void start(final Stage stage) throws Exception { stage.setX(300); stage.setWidth(800); stage.setHeight(400); stage.show(); final Stage childStage = new Stage(); childStage.setWidth(200); childStage.setHeight(200); childStage.setX(stage.getX() + stage.getWidth() / 2 - childStage.getWidth() / 2); childStage.setY(stage.getY() + stage.getHeight() / 2 - childStage.getHeight() / 2); childStage.show(); } public static void main(String[] args) { Application.launch(args); } }
/** * Retrieves data about he window settings from the previous session and applies * them to the stage. These settings include window size, position and if * it was maximized or not. * * @param stage the stage to apply these settings to * @param name the name under which we stored the settings */ public static void applyStoredDisplaySettings(Stage stage, String name){ try { if( PREFERENCES.nodeExists(name) ){ Preferences stagePreferences = PREFERENCES.node(name); boolean wasMaximized = stagePreferences.getBoolean(WINDOW_MAXIMIZED, false); if( wasMaximized ){ stage.setMaximized(true); } else { stage.setX( stagePreferences.getDouble(WINDOW_X_POS, DEFUALT_X)); stage.setY( stagePreferences.getDouble(WINDOW_Y_POS, DEFUALT_Y)); stage.setWidth( stagePreferences.getDouble(WINDOW_WIDTH, DEFUALT_WIDTH)); stage.setHeight(stagePreferences.getDouble(WINDOW_HEIGHT, DEFUALT_HEIHGT)); } } } catch (BackingStoreException ex) { LOGGER.error(ex, "Could not access preferences for window " + name); } }
@Override public void start(Stage primaryStage) { final ToggleGroup group = new ToggleGroup(); JFXRadioButton javaRadio = new JFXRadioButton("JavaFX"); javaRadio.setPadding(new Insets(10)); javaRadio.setToggleGroup(group); JFXRadioButton jfxRadio = new JFXRadioButton("JFoenix"); jfxRadio.setPadding(new Insets(10)); jfxRadio.setToggleGroup(group); VBox vbox = new VBox(); vbox.getChildren().add(javaRadio); vbox.getChildren().add(jfxRadio); vbox.setSpacing(10); HBox hbox = new HBox(); hbox.getChildren().add(vbox); hbox.setSpacing(50); hbox.setPadding(new Insets(40, 10, 10, 120)); Scene scene = new Scene(hbox); primaryStage.setScene(scene); primaryStage.setWidth(500); primaryStage.setHeight(400); primaryStage.setTitle("JFX RadioButton Demo "); scene.getStylesheets() .add(RadioButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); primaryStage.show(); }
@Override public void start(Stage stage) { JFXSlider horLeftSlider = new JFXSlider(); horLeftSlider.setMinWidth(500); JFXSlider horRightSlider = new JFXSlider(); horRightSlider.setMinWidth(500); horRightSlider.setIndicatorPosition(IndicatorPosition.RIGHT); JFXSlider verLeftSlider = new JFXSlider(); verLeftSlider.setMinHeight(500); verLeftSlider.setOrientation(Orientation.VERTICAL); JFXSlider verRightSlider = new JFXSlider(); verRightSlider.setMinHeight(500); verRightSlider.setOrientation(Orientation.VERTICAL); verRightSlider.setIndicatorPosition(IndicatorPosition.RIGHT); HBox hbox = new HBox(); hbox.setSpacing(450); hbox.getChildren().addAll(verRightSlider, verLeftSlider); VBox vbox = new VBox(); vbox.getChildren().addAll(horRightSlider, horLeftSlider, hbox); vbox.setSpacing(100); vbox.setPadding(new Insets(100, 50, 50, 150)); Scene scene = new Scene(new Group()); ((Group) scene.getRoot()).getChildren().add(vbox); scene.getStylesheets().add(SliderDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setScene(scene); stage.setWidth(900); stage.setHeight(900); stage.show(); stage.setTitle("JFX Slider Demo"); }
primaryStage.setWidth(maximizedBox.getWidth()); primaryStage.setHeight(maximizedBox.getHeight()); btnMax.setGraphic(resizeMin); btnMax.setTooltip(new Tooltip("Restore Down")); primaryStage.setWidth(originalBox.getWidth()); primaryStage.setHeight(originalBox.getHeight()); originalBox = null; btnMax.setGraphic(resizeMax);
@Override public void start(Stage mainStage) throws Exception { Scene scene = new Scene(new Region()); mainStage.setWidth(640); mainStage.setHeight(480); mainStage.setScene(scene); //this makes all stages close and the app exit when the main stage is closed mainStage.setOnCloseRequest(e -> Platform.exit()); //add real stuff to the scene... //open secondary stages... etc... }
@Override public void start(final Stage primaryStage) throws Exception { final Dimension d = new Dimension(210, 110); final Rectangle rectangle = new Rectangle(d.width, d.height, Color.POWDERBLUE); final BorderPane pane = new BorderPane(rectangle); pane.maxWidth(d.height); pane.maxWidth(d.width); final Scene scene = new Scene(pane, d.width, d.height); primaryStage.setScene(scene); primaryStage.setResizable(false); primaryStage.setWidth(d.width); primaryStage.setHeight(d.height); primaryStage.show(); }
@FXML public void do() throws Exception { FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("/fxml/myPage.fxml")); Parent root = (Parent)fxmlLoader.load(); Scene mainScene = new Scene(root); Stage stage = new Stage(); stage.setHeight(500); stage.setWidth(400); stage.setScene(mainScene); stage.setTitle("Provide input"); stage.showAndWait(); // get results of input here... System.out.println(Thread.currentThread().getName() +"returned"); }
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(); } }
/** * Set the bounds of the dialog * <p> * <b>Has to be called after {@link #open()}.</b> For initial size and location use * {@link #getInitialSize(Parent)} {@link #getInitialLocation(Parent)} * </p> * * @param x * the x position * @param y * thy y position * @param width * the width * @param height * the height */ public void setBounds(int x, int y, int width, int height) { this.stage.setX(x); this.stage.setY(y); this.stage.setWidth(width); this.stage.setHeight(height); }
@FXML public void do() throws Exception { FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("/fxml/myPage.fxml")); Parent root = (Parent)fxmlLoader.load(); Scene mainScene = new Scene(root); Stage stage = new Stage(); stage.setHeight(500); stage.setWidth(400); stage.setScene(mainScene); stage.setTitle("Provide input"); stage.setOnHidden(e -> { // process input here... }); stage.show(); System.out.println(Thread.currentThread().getName() +"returned"); }
private PopupWindow keyboard; private final Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds(); private final Rectangle2D bounds = Screen.getPrimary().getBounds(); private final double taskbarHeight=bounds.getHeight()-visualBounds.getHeight(); @Override public void start(Stage stage) { TextField tfComment = new TextField(); tfComment.setPromptText("Enter comment"); BorderPane borderPane = new BorderPane(new Button("Click")); borderPane.setBottom(tfComment); Scene scene = new Scene(borderPane); stage.setScene(scene); stage.setX(visualBounds.getMinX()); stage.setY(visualBounds.getMinY()); stage.setWidth(visualBounds.getWidth()); stage.setHeight(visualBounds.getHeight()); stage.show(); }
public class cursor extends Application { @Override public void start(Stage primaryStage) { HBox root = new HBox(); Scene scene = new Scene(root); scene.setCursor(Cursor.NONE); primaryStage.setScene(scene); primaryStage.setWidth(300); primaryStage.setHeight(300); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); scene.setRoot(new BuildLayout(stage)); Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); stage.setTitle("Application Name"); stage.setScene(scene); stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.show(); }