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

The following examples show how to use javafx.stage.Stage#sizeToScene() . 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: Undecorator.java    From DevToolBox with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Prepare Stage for dock feedback display
 */
void buildDockFeedbackStage() {
    dockFeedbackPopup = new Stage(StageStyle.TRANSPARENT);
    dockFeedback = new Rectangle(0, 0, 100, 100);
    dockFeedback.setArcHeight(10);
    dockFeedback.setArcWidth(10);
    dockFeedback.setFill(Color.TRANSPARENT);
    dockFeedback.setStroke(Color.BLACK);
    dockFeedback.setStrokeWidth(2);
    dockFeedback.setCache(true);
    dockFeedback.setCacheHint(CacheHint.SPEED);
    dockFeedback.setEffect(new DropShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 10, 0.2, 3, 3));
    dockFeedback.setMouseTransparent(true);
    BorderPane borderpane = new BorderPane();
    borderpane.setStyle("-fx-background-color:transparent"); //J8
    borderpane.setCenter(dockFeedback);
    Scene scene = new Scene(borderpane);
    scene.setFill(Color.TRANSPARENT);
    dockFeedbackPopup.setScene(scene);
    dockFeedbackPopup.sizeToScene();
}
 
Example 2
Source File: AbstractMvcExample.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void start(final Stage primaryStage) throws Exception {
	this.primaryStage = primaryStage;

	// create domain using guice
	this.domain = Guice.createInjector(createModule()).getInstance(IDomain.class);

	// create viewers
	hookViewers();

	// set-up stage
	primaryStage.setResizable(true);
	primaryStage.setWidth(640);
	primaryStage.setHeight(480);
	primaryStage.setTitle(title);
	primaryStage.sizeToScene();
	primaryStage.show();

	// activate domain
	domain.activate();

	// load contents
	populateViewerContents();
}
 
Example 3
Source File: PasswordFieldApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("PasswordField Sample");
    primaryStage.setScene(new Scene(new PasswordFieldSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 4
Source File: ComboBoxTableViewApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Combo Box TableView");
    primaryStage.setScene(new Scene(new ComboBoxTableViewSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 5
Source File: TreeTableSampleApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("TreeTable View Sample");
    primaryStage.setScene(new Scene(new TreeTableSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
    TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
 
Example 6
Source File: ChoiceBoxTreeTableSampleApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("TreeTable View Sample");
    primaryStage.setScene(new Scene(new ChoiceBoxTreeTableSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
    TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
 
Example 7
Source File: SpinnerApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Spinner");
    primaryStage.setScene(new Scene(new SpinnerSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 8
Source File: ADCPreloader.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
@Override
public void start(Stage preloaderStage) throws Exception {
	this.preloaderStage = preloaderStage;
	preloaderStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
		@Override
		public void handle(WindowEvent event) {
			System.exit(0);
		}
	});

	preloaderStage.setTitle(Lang.Application.APPLICATION_TITLE);
	preloaderStage.getIcons().add(ADCIcons.ICON_ADC);
	progressIndicator.setMaxWidth(48d);
	progressIndicator.setMaxHeight(progressIndicator.getMaxWidth());

	VBox vBox = new VBox(5, progressIndicator, lblProgressText);
	vBox.setAlignment(Pos.CENTER);
	VBox.setVgrow(progressIndicator, Priority.ALWAYS);

	Label lblBuild = new Label("Build: " + ArmaDialogCreator.getManifest().getMainAttributes().getValue("Build-Number"));
	Label lblVersion = new Label("Version: " + ArmaDialogCreator.getManifest().getMainAttributes().getValue("Specification-Version"));
	BorderPane borderPane = new BorderPane(vBox, null, null, new HBox(10, lblBuild, lblVersion), null);
	borderPane.setPadding(new Insets(5));

	StackPane.setMargin(borderPane, new Insets(248, 0, 0, 0));
	StackPane stackpane = new StackPane(new ImageView(ADCImagePaths.PRELOAD_SCREEN), borderPane);
	Scene scene = new Scene(stackpane);
	preloaderStage.initStyle(StageStyle.UNDECORATED);
	preloaderStage.setScene(scene);
	preloaderStage.sizeToScene();
	preloaderStage.show();
}
 
Example 9
Source File: AbstractFxExample.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	primaryStage.setScene(createScene());
	primaryStage.sizeToScene();
	primaryStage.setTitle(title);
	primaryStage.show();
}
 
Example 10
Source File: SliderApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Slider Sample");
    primaryStage.setScene(new Scene(new SliderSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 11
Source File: ComboBoxTreeTableSampleApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("TreeTable View Sample");
    primaryStage.setScene(new Scene(new ComboBoxTreeTableSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
    TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
 
Example 12
Source File: TextFieldListViewSampleApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("ListViewTextField");
    primaryStage.setScene(new Scene(new TextFieldListViewSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 13
Source File: CheckBoxListViewApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("LisViewCheckBox");
    primaryStage.setScene(new Scene(new CheckBoxListViewSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 14
Source File: ChoiceBoxTableViewApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Choice Box TableView");
    primaryStage.setScene(new Scene(new ChoiceBoxTableViewSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 15
Source File: CheckBoxTreeViewApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Check Box TreeView");
    primaryStage.setScene(new Scene(new CheckBoxTreeViewSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 16
Source File: ChoiceBoxTreeViewApp.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Choice Box TreeView");
    primaryStage.setScene(new Scene(new ChoiceBoxTreeViewSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 17
Source File: ErrorDialogue.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
private void resizeAlert() {
    alert.getDialogPane().requestLayout();

    Stage stage = (Stage)alert.getDialogPane().getScene().getWindow();
    stage.sizeToScene();
}
 
Example 18
Source File: ModalDialog.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
protected void initialize(Stage stage) {
    stage.sizeToScene();
}
 
Example 19
Source File: Gui.java    From ARMStrong with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	this.simulator = new ArmSimulator();
	this.executionMode = false;
	this.running = new AtomicBoolean(false);
	this.interfaceBeingUpdated = new AtomicBoolean(false);

	this.stage = primaryStage;

	primaryStage.setTitle("#@RMStrong");
	Image applicationIcon = new Image(Gui.class.getResource("/resources/logo.png").toExternalForm());
	primaryStage.getIcons().add(applicationIcon);
	
	this.dockPane = new DockPane();

	// load an image to caption the dock nodes
	// Image dockImage = new
	// Image(Gui.class.getResource("docknode.png").toExternalForm());

	// creating the nodes
	this.registersViews = new ArrayList<>();
	this.ramViews = new ArrayList<>();
	this.ledViews = new ArrayList<>();
	this.eightSegmentDisplays = new ArrayList<>();
	
	this.codeEditor = new CodeEditor(simulator);
	this.codeEditor.getNode().dock(dockPane, DockPos.LEFT);

	this.registersViews.add(new RegistersView(this.simulator));
	this.registersViews.get(0).getNode().setMaxWidth(220);
	this.registersViews.get(0).getNode().dock(dockPane, DockPos.LEFT);

	this.ramViews.add(new RamView(simulator));
	this.ramViews.get(0).getNode().dock(dockPane, DockPos.RIGHT);


	this.consoleView = new ConsoleView();
	this.consoleView.getNode().dock(dockPane, DockPos.BOTTOM);

	this.consoleView.redirectToConsole();
	
	this.simulator.setConsoleView(this.consoleView);
	
	this.interpreter = new Interpreter(this.simulator);
	this.isInterpreterMode = false;
	
	this.armMenuBar = new ArmMenuBar(this.getHostServices());
	this.armToolBar = new ArmToolBar();

	VBox vbox = new VBox();
	vbox.getChildren().addAll(this.armMenuBar.getNode(), this.armToolBar.getNode(), dockPane);
	VBox.setVgrow(dockPane, Priority.ALWAYS);

	this.scene = new Scene(vbox, 1000, 1000);
	this.stage.setMaximized(true);
	this.stage.setResizable(true);

	primaryStage.setScene(this.scene);
	primaryStage.sizeToScene();

	setButtonEvents();
	setExecutionMode();

	Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);

	newUpdateThread(this.running);
	
	primaryStage.show();
	primaryStage.setOnCloseRequest((WindowEvent event) -> System.exit(0));
	DockPane.initializeDefaultUserAgentStylesheet();
	
	vbox.getStylesheets().add("/resources/style.css");
	
	System.out.println("Welcome to #@RMStrong Simulator made proudly at the Institute of Technology of Valence in 2018-2019 by fellow students under the guidance of Dr. Philippe Objois!");
	System.out.println("Licensed under the MPL 2.0 License");
	System.out.println("Copyright (c) 2018-2019 Valentin D'Emmanuele, Gilles Mertens, Dylan Fraisse, Hugo Chemarin, Nicolas Gervasi");
}
 
Example 20
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public void display() {
    if (owner == null)
        owner = MainView.getRootContainer();

    if (owner != null) {
        Scene rootScene = owner.getScene();
        if (rootScene != null) {
            Scene scene = new Scene(getRootContainer());
            scene.getStylesheets().setAll(rootScene.getStylesheets());
            scene.setFill(Color.TRANSPARENT);

            setupKeyHandler(scene);

            stage = new Stage();
            stage.setScene(scene);
            Window window = rootScene.getWindow();
            setModality();
            stage.initStyle(StageStyle.TRANSPARENT);
            stage.setOnCloseRequest(event -> {
                event.consume();
                doClose();
            });
            stage.sizeToScene();
            stage.show();

            layout();

            addEffectToBackground();

            // On Linux the owner stage does not move the child stage as it does on Mac
            // So we need to apply centerPopup. Further with fast movements the handler loses
            // the latest position, with a delay it fixes that.
            // Also on Mac sometimes the popups are positioned outside of the main app, so keep it for all OS
            positionListener = (observable, oldValue, newValue) -> {
                if (stage != null) {
                    layout();
                    if (centerTime != null)
                        centerTime.stop();

                    centerTime = UserThread.runAfter(this::layout, 3);
                }
            };
            window.xProperty().addListener(positionListener);
            window.yProperty().addListener(positionListener);
            window.widthProperty().addListener(positionListener);

            animateDisplay();
            isDisplayed = true;
        }
    }
}