Example usage for javafx.stage Stage initOwner

List of usage examples for javafx.stage Stage initOwner

Introduction

In this page you can find the example usage for javafx.stage Stage initOwner.

Prototype

public final void initOwner(Window owner) 

Source Link

Document

Specifies the owner Window for this stage, or null for a top-level, unowned stage.

Usage

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    // Table Study
    initializeTable(tableStudy, StudyImpl.class);
    initializeTable(tablePlate, PlateImpl.class);
    initializeTable(tableSample, SampleImpl.class);
    initializeTable(tableInjection, InjectionImpl.class);
    initializeTable(tableCompound, CompoundImpl.class);
    initializeTable(tableHistory, OperationHistoryImpl.class);

    menuBar.setUseSystemMenuBar(true);/*from   w  ww  .j  a va 2 s  . co m*/

    commandManager = new CommandManager();
    commandManager.setContext(commandManagerContext);
    final GUICommandPaneFactory commandPaneFactory = new GUICommandPaneFactory(commandManager);
    MetabolomeQC.addCorrectionCommands(commandManager);
    for (Map.Entry<String, Class> commend : commandManager.getCommands().entrySet()) {
        MenuItem menuItem = new MenuItem(commend.getKey());
        menuItem.setText(commend.getKey());
        menuItem.setOnAction(e -> {
            final Stage stage = new Stage();
            stage.initModality(Modality.WINDOW_MODAL);

            Parent guiCommand = commandPaneFactory.getCommandPane(commend.getKey(),
                    (commandEvent, managedCommand) -> {
                        stage.close();
                    });
            BorderPane margins = new BorderPane(guiCommand);
            BorderPane.setMargin(guiCommand, new Insets(10));

            stage.setScene(new Scene(margins));
            stage.initOwner(this.stage);
            stage.showAndWait();
            onRefresh(null);
        });
        correctionMenu.getItems().add(menuItem);
    }

    onRefresh(null);
}

From source file:qupath.lib.gui.panels.survival.KaplanMeierDisplay.java

private Stage createStage(final Window parent, final String title) {
    Stage frame = new Stage();
    if (parent != null)
        frame.initOwner(parent);
    frame.setTitle("Kaplan Meier: " + title);

    frame.setOnCloseRequest(e -> {/*  w w  w  .  j  av  a2  s  . co  m*/
        if (hierarchy != null)
            hierarchy.removePathObjectListener(KaplanMeierDisplay.this);
        panelParams.removeParameterChangeListener(KaplanMeierDisplay.this);
        frame.hide();
    });

    Scene scene = new Scene(getView(), 600, 400);
    frame.setScene(scene);
    frame.setMinWidth(600);
    frame.setMinHeight(400);
    return frame;
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

private void initGenerateXPathFromStackTrace() {

    ContextMenu menu = new ContextMenu();

    MenuItem item = new MenuItem("Generate from stack trace...");
    item.setOnAction(e -> {/*from   w ww. j  ava2s.  c  o  m*/
        try {
            Stage popup = new Stage();
            FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("generate-xpath-from-stack-trace.fxml"));
            Parent root = loader.load();
            Button button = (Button) loader.getNamespace().get("generateButton");
            TextArea area = (TextArea) loader.getNamespace().get("stackTraceArea");

            ValidationSupport validation = new ValidationSupport();

            validation.registerValidator(area,
                    Validator.createEmptyValidator("The stack trace may not be empty"));
            button.disableProperty().bind(validation.invalidProperty());

            button.setOnAction(f -> {
                DesignerUtil.stackTraceToXPath(area.getText()).ifPresent(xpathExpressionArea::replaceText);
                popup.close();
            });

            popup.setScene(new Scene(root));
            popup.initStyle(StageStyle.UTILITY);
            popup.initModality(Modality.WINDOW_MODAL);
            popup.initOwner(designerRoot.getMainStage());
            popup.show();
        } catch (IOException e1) {
            throw new RuntimeException(e1);
        }
    });

    menu.getItems().add(item);

    xpathExpressionArea.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
        if (t.getButton() == MouseButton.SECONDARY) {
            menu.show(xpathExpressionArea, t.getScreenX(), t.getScreenY());
        }
    });
}

From source file:genrsa.GenRSAController.java

/**
 * Muestra por pantalla la informacin relativa a genRSA 
 * @param event /*from w w w . j av a  2 s. co  m*/
 */
public void aboutGenRSA(ActionEvent event) {
    Stage stage;
    FXMLLoader fxmlLoader;
    Parent root;

    try {
        stage = new Stage();
        fxmlLoader = new FXMLLoader(getClass().getResource("/About/About.fxml"));
        root = fxmlLoader.load();

        Scene scene = new Scene(root);
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.initOwner(this.unitsD.getScene().getWindow());
        stage.setResizable(false);
        stage.getIcons().add(new Image(GenRSAController.class.getResourceAsStream("/allImages/genRSA.png")));
        stage.setTitle("Acerca de genRSA v2.1");
        stage.setScene(scene);
        stage.show();

    } catch (IOException ex) {
        //no pongo mensaje de error, porque no se puede dar el caso
    }

}

From source file:com.github.drbookings.ui.controller.MainController.java

private void showAddBookingDialog(final LocalDate date, final String roomName) {
    try {//from www .  j av a  2s  .com
        final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/AddBookingView.fxml"));
        final Parent root = loader.load();
        final Stage stage = new Stage();
        stage.setWidth(300);
        stage.setHeight(600);
        final Scene scene = new Scene(root);
        stage.setTitle("Add BookingBean");
        stage.setScene(scene);
        final AddBookingController c = loader.getController();
        c.setManager(manager);
        c.datePickerCheckIn.setValue(date);
        c.comboBoxRoom.getSelectionModel().select(roomName);
        final Stage windowStage = (Stage) node.getScene().getWindow();
        stage.initOwner(windowStage);
        stage.initModality(Modality.WINDOW_MODAL);
        stage.setX(windowStage.getX() + windowStage.getWidth() / 2 - stage.getWidth() / 2);
        stage.setY((windowStage.getY() + windowStage.getHeight()) / 2 - stage.getHeight() / 2);
        stage.show();
    } catch (final IOException e) {
        logger.error(e.getLocalizedMessage(), e);
    }
}

From source file:ui.ChoseFonctionnalite.java

private void startClientMode(ActionEvent eventT) {
    //File config = new File("resource/config.json");
    String host = "";
    String port = "8000";
    Stage stageModal = new Stage();
    Pane root = new Pane();
    root.setBackground(new Background(new BackgroundImage(new Image("resource/background.jpg"),
            BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
            new BackgroundSize(530, 400, true, true, true, true))));
    stageModal.setScene(new Scene(root, 200, 200));
    stageModal.initStyle(StageStyle.UTILITY);
    Label adresse = new Label("Adresse serveur:");
    adresse.setLayoutX(10);/*  www  . j a v a  2s.c o m*/
    adresse.setLayoutY(10);
    adresse.setFont(Font.font("Arial", 16));
    JFXTextField adresseInput = new JFXTextField("127.0.0.1");
    adresseInput.setPrefWidth(180);
    adresseInput.setLayoutX(10);
    adresseInput.setLayoutY(40);
    JFXButton valider = new JFXButton("Se connecter");
    valider.setCursor(Cursor.HAND);
    valider.setMinSize(100, 30);
    valider.setLayoutX(20);
    valider.setLayoutY(130);
    valider.setFont(new Font(20));
    valider.setStyle("-fx-background-color: #9E21FF;");
    valider.setOnAction(event -> {
        if (adresseInput.getText() != "") {
            stageModal.close();
            InitClient initializeClient = new InitClient(stage, adresseInput.getText(), port);
        }
    });
    root.getChildren().add(valider);
    root.getChildren().add(adresse);
    root.getChildren().add(adresseInput);
    stageModal.setTitle("Adresse serveur");
    stageModal.initModality(Modality.WINDOW_MODAL);
    stageModal.initOwner(((Node) eventT.getSource()).getScene().getWindow());
    stageModal.show();
}

From source file:org.simmi.GeneSetHead.java

License:asdf

public void fetchGenomes() {
    if (geneset.zippath == null) {
        newFile();// w w  w. j a v  a2 s.c om
    }

    VBox vbox = new VBox();

    Stage stage = new Stage();
    stage.setTitle("Fetch genomes");
    stage.setScene(new Scene(vbox));
    stage.initOwner(primaryStage);

    //frame.setSize(400, 600);

    try {
        Map<String, String> env = new HashMap<>();
        env.put("create", "true");
        //Path path = zipfile.toPath();
        String uristr = "jar:" + geneset.zippath.toUri();
        geneset.zipuri = URI.create(uristr /*.replace("file://", "file:")*/ );
        geneset.zipfilesystem = FileSystems.newFileSystem(geneset.zipuri, env);

        final SerifyApplet sa = new SerifyApplet(geneset.zipfilesystem);
        sa.init(frame, vbox, geneset.user);

        for (Path root : geneset.zipfilesystem.getRootDirectories()) {
            Files.list(root).filter(t -> {
                String fname = t.getFileName().toString();
                return /*fname.endsWith(".gbk") || */fname.endsWith(".fna") || fname.endsWith("fastg")
                        || fname.endsWith(".fsa") || fname.endsWith(".fa") || fname.endsWith(".fasta")
                        || fname.endsWith(".aa") || fname.endsWith(".nn") || fname.endsWith(".trna")
                        || fname.endsWith(".rrna") || fname.endsWith(".ssu") || fname.endsWith(".lsu")
                        || fname.endsWith(".tsu");
            }).forEach(t -> {
                try {
                    sa.addSequences(t.getFileName().toString(), t, null);
                } catch (URISyntaxException | IOException e) {
                    e.printStackTrace();
                }
            });
            ;
        }
    } catch (IOException e1) {
        try {
            geneset.zipfilesystem.close();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
        e1.printStackTrace();
    }

    //BufferedWriter bw = Files.newBufferedWriter(nf, StandardOpenOption.CREATE);

    //InputStream is = new GZIPInputStream( new FileInputStream( fc.getSelectedFile() ) );
    //uni2symbol(new InputStreamReader(is), bw, unimap);

    //bw.close();
    //long bl = Files.copy( new ByteArrayInputStream( baos.toByteArray() ), nf, StandardCopyOption.REPLACE_EXISTING );

    /*frame.addWindowListener( new WindowListener() {
               
       @Override
       public void windowOpened(WindowEvent e) {}
               
       @Override
       public void windowIconified(WindowEvent e) {}
               
       @Override
       public void windowDeiconified(WindowEvent e) {}
               
       @Override
       public void windowDeactivated(WindowEvent e) {}
               
       @Override
       public void windowClosing(WindowEvent e) {}
               
       @Override
       public void windowClosed(WindowEvent e) {
    try {
       geneset.zipfilesystem.close();
            
       geneset.cleanUp();
       importStuff();
    } catch (IOException | UnavailableServiceException e1) {
       e1.printStackTrace();
    }
       }
               
       @Override
       public void windowActivated(WindowEvent e) {}
    });
            
    frame.setVisible( true );*/

    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
        public void handle(WindowEvent event) {
            try {
                geneset.zipfilesystem.close();

                geneset.cleanUp();
                importStuff();
            } catch (IOException | UnavailableServiceException e1) {
                e1.printStackTrace();
            }
        }
    });
    stage.show();
}