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

The following examples show how to use javafx.stage.Stage#initOwner() . 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: MainController.java    From MusicPlayer with MIT License 7 votes vote down vote up
private void createSearchPopup() {
	try {

		Stage stage = MusicPlayer.getStage();
		VBox view = new VBox();
           view.getStylesheets().add(Resources.CSS + "MainStyle.css");
           view.getStyleClass().add("searchPopup");
		Stage popup = new Stage();
		popup.setScene(new Scene(view));
		popup.initStyle(StageStyle.UNDECORATED);
		popup.initOwner(stage);
		searchHideAnimation.setOnFinished(x -> popup.hide());

		popup.show();
		popup.hide();
		searchPopup = popup;

	} catch (Exception ex) {

		ex.printStackTrace();
	}
}
 
Example 2
Source File: UiHelper.java    From tcMenu with Apache License 2.0 6 votes vote down vote up
public static void createDialogStateAndShowSceneAdj(Stage parent, Pane root, String title, boolean modal,
                                                    BiConsumer<Scene, Stage> sceneAdjuster) {
    Stage dialogStage = new Stage();
    dialogStage.setTitle(title);
    dialogStage.initOwner(parent);

    Scene scene = new Scene(root);
    sceneAdjuster.accept(scene, dialogStage);

    dialogStage.setScene(scene);
    if (modal) {
        dialogStage.initModality(Modality.WINDOW_MODAL);
        dialogStage.showAndWait();
    }
    else {
        dialogStage.show();
    }
}
 
Example 3
Source File: GUIController.java    From dctb-utfpr-2018-1 with Apache License 2.0 6 votes vote down vote up
public void startApp(Stage stage) {
    mainStage = stage;
    modalStage = new Stage();
    modalStage.initOwner(mainStage);
    modalStage.initModality(Modality.APPLICATION_MODAL);
    
    mainStage.setMinWidth(1280);
    mainStage.setMinHeight(720);
    
    try {
        indexParent = FXMLLoader.load(getClass().getResource("register/CustomerRegister.fxml"));
    } catch (IOException ex) {
        Logger.getLogger(GUIController.class.getName()).log(Level.SEVERE, null, ex);
    }
    nowScene = new Scene(indexParent);
    
    executionStack.push(nowScene);
    
    mainStage.setScene(nowScene);
    mainStage.show();
}
 
Example 4
Source File: GUIController.java    From dctb-utfpr-2018-1 with Apache License 2.0 6 votes vote down vote up
public void startApp(Stage stage) {
    mainStage = stage;
    modalStage = new Stage();
    modalStage.initOwner(mainStage);
    modalStage.initModality(Modality.APPLICATION_MODAL);
    
    mainStage.setMinWidth(1280);
    mainStage.setMinHeight(720);
    
    try {
        indexParent = FXMLLoader.load(getClass().getResource("register/EmployeeRegister.fxml"));
    } catch (IOException ex) {
        Logger.getLogger(GUIController.class.getName()).log(Level.SEVERE, null, ex);
    }
    nowScene = new Scene(indexParent);
    
    executionStack.push(nowScene);
    
    mainStage.setScene(nowScene);
    mainStage.show();
}
 
Example 5
Source File: CurlyApp.java    From curly with Apache License 2.0 6 votes vote down vote up
public static void openActivityMonitor(BatchRunner runner) {
    try {
        FXMLLoader loader = new FXMLLoader(CurlyApp.class.getResource("/fxml/RunnerReport.fxml"));
        loader.setResources(ApplicationState.getInstance().getResourceBundle());
        loader.load();
        RunnerActivityController runnerActivityController = loader.getController();

        Stage popup = new Stage();
        popup.setScene(new Scene(loader.getRoot()));
        popup.initModality(Modality.APPLICATION_MODAL);
        popup.initOwner(applicationWindow);

        runnerActivityController.attachRunner(runner);

        popup.showAndWait();
    } catch (IOException ex) {
        Logger.getLogger(CurlyApp.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 6
Source File: FxmlStage.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public static BaseController openStage(Stage myStage,
        String newFxml, boolean isOwned, Modality modality,
        StageStyle stageStyle) {
    try {
        Stage stage = new Stage();
        stage.initModality(modality);
        if (isOwned && myStage != null) {
            stage.initOwner(myStage);
        } else {
            stage.initOwner(null);
        }
        return initScene(stage, newFxml, stageStyle);
    } catch (Exception e) {
        logger.error(e.toString());
        return null;
    }
}
 
Example 7
Source File: MenuControllerApp.java    From tcMenu with Apache License 2.0 6 votes vote down vote up
private RemoteMenuController showConfigChooser(MenuTree tree) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/remoteSelector.fxml"));
    BorderPane pane = loader.load();
    RemoteSelectorController controller = loader.getController();
    controller.init(tree);

    Stage dialogStage = new Stage();
    dialogStage.getIcons().add(new Image(getClass().getResourceAsStream("/controller-icon.png")));
    dialogStage.setTitle("Connect to tcMenu device");
    dialogStage.initModality(Modality.WINDOW_MODAL);
    dialogStage.initOwner(null);
    Scene scene = new Scene(pane);
    dialogStage.setScene(scene);
    dialogStage.showAndWait();
    return controller.getResult();
}
 
Example 8
Source File: CurlyApp.java    From curly with Apache License 2.0 6 votes vote down vote up
public static void importWizard(Consumer<List<Map<String, String>>> handler) {
    try {
        FXMLLoader loader = new FXMLLoader(CurlyApp.class.getResource("/fxml/DataImporter.fxml"));
        loader.setResources(ApplicationState.getInstance().getResourceBundle());
        loader.load();
        DataImporterController importController = loader.getController();

        Stage popup = new Stage();
        popup.setScene(new Scene(loader.getRoot()));
        popup.initModality(Modality.APPLICATION_MODAL);
        popup.initOwner(applicationWindow);

        importController.setActions(appController.getActions());
        importController.setFinishImportHandler(handler);
        importController.whenFinished(popup::close);

        popup.showAndWait();
    } catch (IOException ex) {
        Logger.getLogger(CurlyApp.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 9
Source File: DragAndDropHandler.java    From FxDock with Apache License 2.0 5 votes vote down vote up
protected static Stage createDragWindow(FxDockPane client)
{
	Window owner = FX.getParentWindow(client);
	Image im = createDragImage(client);
	Pane p = new Pane(new ImageView(im));
	Stage s = new Stage(StageStyle.TRANSPARENT);
	s.initOwner(owner);
	s.setScene(new Scene(p, im.getWidth(), im.getHeight()));
	s.setOpacity(DRAG_WINDOW_OPACITY);
	return s;
}
 
Example 10
Source File: Controller.java    From game-of-life-java with MIT License 5 votes vote down vote up
@FXML
private void onAbout(Event evt) {
    // TEXT //
    Text text1 = new Text("Conway's Game of Life\n");
    text1.setFont(Font.font(30));
    Text text2 = new Text(
            "\nThe Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.\n"
                    + "The game is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves or, for advanced players, by creating patterns with particular properties."
            );
    Text text3 = new Text("\n\nRules\n");
    text3.setFont(Font.font(20));
    Text text4 = new Text(
            "\nThe universe of the Game of Life is a two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:\n"
                    +"\n1) Any live cell with fewer than two live neighbours dies, as if caused by under-population.\n"
                    +"2) Any live cell with two or three live neighbours lives on to the next generation.\n"
                    +"3) Any live cell with more than three live neighbours dies, as if by overcrowding.\n"
                    +"4) Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.\n\nMore on Wikipedia:\n"
            );

    Hyperlink link = new Hyperlink("http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life <-------not working");
    TextFlow tf = new TextFlow(text1,text2,text3,text4,link);
    tf.setPadding(new Insets(10, 10, 10, 10));
    tf.setTextAlignment(TextAlignment.JUSTIFY);
    // END TEXT, START WINDOW //
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(new Stage());
    VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(tf);
    Scene dialogScene = new Scene(dialogVbox, 450, 500);
    dialog.setScene(dialogScene);
    dialog.show();
    // END WINDOW //
}
 
Example 11
Source File: LaunchScreeenController.java    From FakeImageDetection with GNU General Public License v3.0 5 votes vote down vote up
@FXML
private void loadBatchImageTester(ActionEvent event) throws Exception {
    BatchImageTester tester = new BatchImageTester();
    Stage stage = new Stage();
    stage.initOwner(rootPane.getScene().getWindow());
    stage.initModality(Modality.WINDOW_MODAL);
    tester.start(stage);
}
 
Example 12
Source File: MainController.java    From MusicPlayer with MIT License 5 votes vote down vote up
private void createVolumePopup() {
	try {
		
		Stage stage = MusicPlayer.getStage();
    	FXMLLoader loader = new FXMLLoader(this.getClass().getResource(Resources.FXML + "VolumePopup.fxml"));
    	HBox view = loader.load();
    	volumePopupController = loader.getController();
    	Stage popup = new Stage();
    	popup.setScene(new Scene(view));
    	popup.initStyle(StageStyle.UNDECORATED);
    	popup.initOwner(stage);
    	popup.setX(stage.getWidth() - 270);
    	popup.setY(stage.getHeight() - 120);
    	popup.focusedProperty().addListener((x, wasFocused, isFocused) -> {
    		if (wasFocused && !isFocused) {
    			volumeHideAnimation.play();
    		}
    	});
    	volumeHideAnimation.setOnFinished(x -> popup.hide());
    	
    	popup.show();
    	popup.hide();
    	volumePopup = popup;
    	
	} catch (Exception ex) {
		
		ex.printStackTrace();
	}
}
 
Example 13
Source File: Dialog.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Dialog(Stage parentStage) {
    this.response = new CompletableFuture<>();

    // TODO Calling an overridable method during construction should be
    // fixed via an API change
    Scene scene = new Scene(content(), width, height); // NOPMD
    stage = new Stage();
    stage.setScene(scene);
    stage.setTitle(title);
    stage.setOnCloseRequest(this::onClose);
    stage.initOwner(parentStage);
    Modality modality = Modality.APPLICATION_MODAL;
    stage.initModality(modality);
    stage.initStyle(stageStyle);
}
 
Example 14
Source File: AuxclasspathSetupController.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Displays the popup. */
public void show(Stage parentStage, List<File> currentItems, Consumer<List<File>> onApply) {

    FXMLLoader fxmlLoader = new FXMLLoader(DesignerUtil.getFxml("auxclasspath-setup-popup"));

    fxmlLoader.setControllerFactory(type -> {
        if (type == AuxclasspathSetupController.class) {
            return this;
        } else {
            throw new IllegalStateException("Wrong controller!");
        }
    });

    Stage stage = new Stage();
    try {
        stage.setScene(new Scene(fxmlLoader.load()));
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }

    fileListView.setItems(FXCollections.observableArrayList(currentItems));

    stage.setTitle("Auxilliary classpath setup");
    stage.initOwner(parentStage);
    stage.initModality(Modality.WINDOW_MODAL);

    setClassPathButton.setOnAction(e -> {
        stage.close();
        onApply.accept(fileListView.getItems());
    });

    cancelButton.setOnAction(e -> stage.close());

    stage.show();
}
 
Example 15
Source File: InternalFXMLLoader.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * ウインドウを開く
 *
 * @param name リソース
 * @param parent 親ウインドウ
 * @param title ウインドウタイトル
 * @param sceneFunction シーン・グラフを操作するFunction
 * @param controllerConsumer コントローラーを操作するConsumer
 * @param windowConsumer ウインドウを操作するConsumer
 * @throws IOException 入出力例外が発生した場合
 */
static void showWindow(String name, Stage parent, String title, Function<Parent, Scene> sceneFunction,
        Consumer<WindowController> controllerConsumer,
        Consumer<Stage> windowConsumer) throws IOException {

    FXMLLoader loader = load(name);
    Stage stage = new Stage();
    Parent root = setGlobal(loader.load());
    if (sceneFunction != null) {
        stage.setScene(sceneFunction.apply(root));
    } else {
        stage.setScene(new Scene(root));
    }

    WindowController controller = loader.getController();
    controller.initWindow(stage);

    if (windowConsumer != null) {
        windowConsumer.accept(stage);
    }
    if (controllerConsumer != null) {
        controllerConsumer.accept(controller);
    }

    stage.initOwner(parent);
    stage.setTitle(title);
    Tools.Windows.setIcon(stage);
    Tools.Windows.defaultCloseAction(controller);
    Tools.Windows.defaultOpenAction(controller);
    stage.show();
}
 
Example 16
Source File: TopsoilWindow.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
public void loadTopsoilWindow(double x, double y) {

        Pane topsoilPlotUI = topsoilPlot.initializePlotPane();

        Scene topsoilPlotScene = new Scene(topsoilPlotUI, 900, 600);
                
        setScene(topsoilPlotScene);
        
        topsoilPlotWindow = new Stage(StageStyle.DECORATED);

        topsoilPlotWindow.setX(x);
        topsoilPlotWindow.setY(y);
        topsoilPlotWindow.setResizable(true);
        topsoilPlotWindow.setScene(topsoilPlotScene);
        topsoilPlotWindow.setTitle("Topsoil Plot");

        topsoilPlotWindow.requestFocus();
        topsoilPlotWindow.initOwner(null);
        topsoilPlotWindow.initModality(Modality.NONE);

        topsoilPlotWindow.show();

    }
 
Example 17
Source File: OpenLabelerController.java    From OpenLabeler with Apache License 2.0 4 votes vote down vote up
@FXML
private void onAbout(ActionEvent actionEvent) {
    Stage aboutDialog = OpenLabeler.createAboutStage(bundle);
    aboutDialog.initOwner(tagBoard.getScene().getWindow());
    aboutDialog.showAndWait();
}
 
Example 18
Source File: EditThemeScheduleActionHandler.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Edit the theme of the currently selected item in the schedule.
 *
 * @param t the action event.
 */
@Override
public void handle(ActionEvent t) {
    TextDisplayable firstSelected = selectedDisplayable;
    if (selectedDisplayable == null) {
        firstSelected = (TextDisplayable) QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList().getSelectionModel().getSelectedItem();
    }
    InlineCssTextArea wordsArea = new InlineCssTextArea();
    wordsArea.replaceText(firstSelected.getSections()[0].toString().trim());
    Button confirmButton = new Button(LabelGrabber.INSTANCE.getLabel("ok.button"), new ImageView(new Image("file:icons/tick.png")));
    Button cancelButton = new Button(LabelGrabber.INSTANCE.getLabel("cancel.button"), new ImageView(new Image("file:icons/cross.png")));
    final Stage s = new Stage();
    s.initModality(Modality.APPLICATION_MODAL);
    s.initOwner(QueleaApp.get().getMainWindow());
    s.resizableProperty().setValue(false);
    final BorderPane bp = new BorderPane();
    final ThemePanel tp = new ThemePanel(wordsArea, confirmButton, true);
    tp.setPrefSize(500, 500);
    if (firstSelected.getSections().length > 0) {
        tp.setTheme(firstSelected.getSections()[0].getTheme());
    }
    confirmButton.setOnAction(e -> {
        if (tp.getTheme() != null) {
            ScheduleList sl = QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList();
            tp.updateTheme(false);
            List<Displayable> displayableList;
            if (selectedDisplayable == null) {
                displayableList = sl.getSelectionModel().getSelectedItems();
            } else {
                displayableList = new ArrayList<>();
                displayableList.add(selectedDisplayable);
            }
            for (Displayable eachDisplayable : displayableList) {
                if (eachDisplayable instanceof TextDisplayable) {
                    ((TextDisplayable) eachDisplayable).setTheme(tp.getTheme());
                    for (TextSection ts : ((TextDisplayable) eachDisplayable).getSections()) {
                        ts.setTheme(tp.getTheme());
                    }
                    if (eachDisplayable instanceof SongDisplayable) {
                        Utils.updateSongInBackground((SongDisplayable) eachDisplayable, true, false);
                    }
                }
            }
            QueleaApp.get().getMainWindow().getMainPanel().getPreviewPanel().refresh();
        }
        s.hide();
    });
    cancelButton.setOnAction(e -> {
        s.hide();
    });
    bp.setCenter(tp);

    HBox hb = new HBox(10);
    hb.setPadding(new Insets(10));
    BorderPane.setAlignment(hb, Pos.CENTER);
    hb.setAlignment(Pos.CENTER);
    hb.getChildren().addAll(confirmButton, cancelButton);
    bp.setBottom(hb);

    Scene scene = new Scene(bp);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    s.setScene(scene);
    s.setMinHeight(600);
    s.setMinWidth(250);
    s.showAndWait();
}
 
Example 19
Source File: GetGroupIdentifier.java    From strongbox with Apache License 2.0 4 votes vote down vote up
public Optional<SecretsGroupIdentifier> getGroupIdentifier() {
    Stage dialog = new Stage();
    dialog.initModality(Modality.WINDOW_MODAL);
    dialog.initOwner(parent);
    dialog.initStyle(StageStyle.UTILITY);

    VBox layout = new VBox();
    Label label = new Label("Create Secrets Group");

    Text nameLabel = new Text("Name:");
    TextField name = new TextField();
    HBox n = new HBox();
    n.getChildren().addAll(nameLabel, name);

    ObservableList<Region> regions =
            FXCollections.observableArrayList(Region.values());

    Text regionLabel = new Text("Region:");
    ComboBox<Region> region = new ComboBox<>(regions);
    region.setValue(defaultRegion);


    HBox r = new HBox();
    r.getChildren().addAll(regionLabel, region);

    HBox actions = new HBox();
    Button create = new Button("Create");
    Button cancel = new Button("Cancel");
    actions.getChildren().addAll(create, cancel);

    create.setOnAction(f -> {
        if (name.getText() != null) {
            secretsGroupIdentifier = Optional.of(new SecretsGroupIdentifier(region.getValue(), name.getText()));
        }
        dialog.close();
    });

    cancel.setOnAction(f -> {
        dialog.close();
    });

    layout.getChildren().addAll(label, n, r, actions);

    Scene scene2 = new Scene(layout, 370, 250);
    dialog.setScene(scene2);

    dialog.showAndWait();


    return secretsGroupIdentifier;
}
 
Example 20
Source File: NameEditor.java    From OpenLabeler with Apache License 2.0 4 votes vote down vote up
public String showPopup(double screenX, double screenY, Window window) {
    Scene scene = new Scene(this);
    Stage popupStage = new Stage(StageStyle.UNDECORATED);
    String label = text.getText();
    popupStage.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
        switch (event.getCode()) {
            case ESCAPE: {
                text.setText(label); // discard change
                popupStage.close();
                break;
            }
            case ENTER: {
                int index = list.getSelectionModel().getSelectedIndex();
                if (index >= 0) {
                    text.setText(list.getSelectionModel().getSelectedItem());
                }
                if (text.getText().trim().isEmpty()) {
                    text.setText(label);
                }
                popupStage.close();
                break;
            }
            case UP: {
                list.requestFocus();
                break;
            }
            case DOWN: {
                list.requestFocus();
                if (list.getSelectionModel().getSelectedIndex() < 0) {
                    list.getSelectionModel().select(0);
                }
                break;
            }
            // JavaFX bug - ListView#selectionModel#select does not scroll into view
            /*
            case UP: {
                int index = list.getSelectionModel().getSelectedIndex();
                index = index < 0 ? 0 : (index == 0 ? list.getItems().size() - 1 : index - 1);
                list.getSelectionModel().select(index);
                event.consume();
                break;
            }
            case DOWN: {
                int index = list.getSelectionModel().getSelectedIndex();
                index = index < 0 ? 0 : (index == list.getItems().size() - 1 ? 0 : index + 1);
                list.getSelectionModel().select(index);
                event.consume();
                break;
            }
            */
        }
    });
    popupStage.focusedProperty().addListener((obs, wasFocused, isNowFocused) -> {
        if (!isNowFocused) {
            if (text.getText().trim().isEmpty()) {
                text.setText(label);
            }
            popupStage.hide();
        }
    });
    popupStage.initOwner(window);
    popupStage.initModality(Modality.WINDOW_MODAL);
    popupStage.setScene(scene);

    // Show the stage close to the mouse pointer
    popupStage.setX(screenX + 10);
    popupStage.setY(screenY + 10);

    popupStage.showAndWait();
    return text.getText();
}