Example usage for javafx.stage Stage Stage

List of usage examples for javafx.stage Stage Stage

Introduction

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

Prototype

public Stage() 

Source Link

Document

Creates a new instance of decorated Stage .

Usage

From source file:de.micromata.mgc.javafx.ControllerService.java

public <M, C extends AbstractModelController<M>> C loadAsDialog(AbstractMainWindow<?> mainWindow,
        Class<C> controllerClass, String dialogTitle) {
    Pair<Pane, C> pair = loadControllerControl(controllerClass, Pane.class, mainWindow);
    Stage stage = new Stage();
    stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, e -> {
        stage.hide();/*  www  .ja  v a2 s . c  o  m*/
        e.consume();
    });
    Pane root = pair.getFirst();
    C controller = pair.getSecond();
    Scene s = new Scene(root);//, AbstractConfigDialog.PREF_WIDTH, AbstractConfigDialog.PREF_HEIGHT
    controller.setParent(root);
    controller.setScene(s);
    controller.setStage(stage);
    stage.setScene(s);
    stage.initModality(Modality.APPLICATION_MODAL);
    //stage.setResizable(false);
    stage.setTitle(dialogTitle);
    return controller;
}

From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java

public void actionOpen() {
    Branch branch = currentBranchValue();
    if (branch == null || branch.schema == null)
        return;//from  w ww.  ja  v  a  2 s  .com

    Stage stage = new Stage();
    EditSchema edit = new EditSchema(stage);
    edit.loadFile(null, branch.schema);
    stage.show();
}

From source file:pe.edu.system.jcmr.util.UtilidadesFx.java

public void openWindow(String fxml) {
    try {/*from ww  w.  j  a v  a 2 s  . c  o m*/
        Stage st = new Stage();

        String lenguage = (String) SessionJCMR.getInstance().getContextObject("Lenguage");
        log.debug("Open window , idioma :" + lenguage);
        Locale currentLocale = new Locale(lenguage);

        ResourceBundle rb = ResourceBundle.getBundle("in18/systemJCMR", currentLocale);
        Parent root;
        root = FXMLLoader.load(getClass().getResource(fxml), rb);
        Scene scena = new Scene(root);
        st.setScene(scena);
        st.show();
    } catch (IOException e) {

        e.printStackTrace();
    }

}

From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java

private void bulkAddWords() {
    Stage stage = new Stage();
    BulkAddWordsView view = new BulkAddWordsView();
    stage.setScene(new SceneStyler().createScene(view, SceneStyler.Style.TOPIC_LIST));
    stage.setTitle(Messages.msg("form.bulk_add_something", Messages.msg("form.word_and_description")));
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.initOwner(getScene().getWindow());
    stage.showAndWait();//from   w ww  .j  av  a 2s  .  c om
    loadRows(view.getCards());
}

From source file:org.mskcc.shenkers.view.IntervalViewNGTest.java

@Test
public void testGenericStackedIntervalView() throws InterruptedException {
    List<Pair<Integer, Integer>> intervals = Arrays.asList(new Pair(0, 1), new Pair(1, 2), new Pair(2, 3),
            new Pair(3, 4), new Pair(4, 5), new Pair(5, 6));
    List<Pane> nodes = intervals.stream().map(i -> new RectangleIntervalNode()).collect(Collectors.toList());
    GenericStackedIntervalView p = new GenericStackedIntervalView(0, 6);
    p.setData(intervals, nodes);/*ww  w  .ja  va2  s  .c o m*/

    ScrollPane sp = new ScrollPane(p);
    ScrollBar sb = new ScrollBar();
    sb.maxProperty().bind(sp.vmaxProperty());
    sb.minProperty().bind(sp.vminProperty());
    sb.visibleAmountProperty().bind(sp.heightProperty().divide(p.prefHeightProperty()));
    sb.setOrientation(Orientation.VERTICAL);
    sp.vvalueProperty().bindBidirectional(sb.valueProperty());
    HiddenSidesPane hsp = new HiddenSidesPane();
    hsp.setContent(sp);
    hsp.setRight(sb);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    p.setOrientation(Orientation.VERTICAL);
    p.prefTileHeightProperty().bind(new SimpleDoubleProperty(40));
    //        p.minHeightProperty().bind(new SimpleDoubleProperty(20).multiply(Bindings.size(p.getChildren())));
    p.prefTileWidthProperty().bind(sp.widthProperty());
    p.prefHeightProperty()
            .bind(new SimpleDoubleProperty(50).multiply(Bindings.size(p.getChildren())).subtract(10));
    p.prefWidthProperty().bind(sp.widthProperty());
    sp.setPadding(Insets.EMPTY);
    p.setVgap(10);

    CountDownLatch l = new CountDownLatch(1);
    Platform.runLater(() -> {

        Stage stage = new Stage();
        stage.setOnHidden(e -> {
            l.countDown();
        });
        Scene scene = new Scene(hsp, 300, 300, Color.GRAY);
        stage.setTitle("GenericStackedPaneTest");
        stage.setScene(scene);
        stage.show();

    });
    l.await();
}

From source file:fr.amap.commons.javafx.chart.ChartViewer.java

public ChartViewer(String title, int width, int height, int maxChartNumberInARow) {

    stage = new Stage();
    stage.setTitle(title);//from   ww w.  ja va2 s  .c o m
    stage.setWidth(width);
    stage.setHeight(height);

    this.maxChartNumberInARow = maxChartNumberInARow;

    this.setContextMenu(createContextMenu());

    vBoxPane = new VBox();
    scrollPane = new ScrollPane();
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setFitToHeight(true);
    scrollPane.setFitToWidth(true);
    scrollPane.setPannable(true);

    scrollPane.setOnMouseClicked(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            MouseButton button = event.getButton();
            if (button == MouseButton.SECONDARY) {
                menu.show(stage, event.getScreenX(), event.getScreenY());
            }
        }
    });

    scrollPane.widthProperty().addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            refreshChartPositionAndSize();
        }
    });

    scrollPane.heightProperty().addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            refreshChartPositionAndSize();
        }
    });

    vBoxPane.getChildren().add(new HBox());
    scrollPane.setContent(vBoxPane);

    chartCanvasList = new ArrayList<>();
    stage.setScene(new Scene(scrollPane));

}

From source file:ca.wumbo.doommanager.client.controller.FileEditorController.java

/**
 * Creates a new DXML project and has the user set it up, then places it in
 * the tab.//from   ww w .  j a  va2  s.c om
 */
public void newDXMLProject() {
    // Create the wizard and wait for the result.
    DXMLProjectCreatorController controller = SpringContainer.getContext()
            .getBean(DXMLProjectCreatorController.class);

    Scene scene = new Scene(controller.getRootPane());
    scene.getStylesheets().add(cssPath);

    Stage stage = new Stage();
    stage.setTitle("DXML Project Setup Wizard");
    stage.setResizable(false);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initOwner(coreController.getStage());
    stage.setScene(scene);
    controller.setStage(stage); // Required for it to be able to close properly.
    controller.setParentStage(coreController.getStage()); // Required as well to block input if browsing for files.
    stage.showAndWait();

    // If the user finished the work, get the DXML file.
    if (!controller.wasClosedByUser()) {
        DXML dxmlData = controller.getDxmlData();
        // The file must also be valid. This should not ever be false unless there is a coding error.
        if (dxmlData.isValidDXMLFile()) {
            // Create it on the disk.
            DXMLCreationStatus status = dxmlData.createOnDisk();

            // If the status shows success, add it to the view.
            switch (status) {
            case SUCCESS:
                // Since it succeeded, open up the project now.
                String path = dxmlData.getProjectInfo().getProjectLocationPath() + File.separator;
                path += dxmlData.getCompilation().getFilename() + File.separator;
                path += dxmlData.getCompilation().getFilename() + ".dxml"; // TODO - support any case extension.
                openDXMLProject(Paths.get(path));
                break;
            case ALREADY_EXISTS:
                log.warn("DXML project already exists at the specified location. Aborting.");
                break;
            case FOLDER_CREATION_FAILURE:
                log.warn("Unable to create directory for the project. Are your permissions correct? Aborting.");
                break;
            case DXML_FILE_EXISTS:
                log.warn("DXML file already exists at location, aborting to prevent potential overwrite.");
                break;
            case DXML_FILE_CREATION_FAILURE:
                log.warn("Unable to create DXML file at location, are your permissions correct? Aborting.");
                break;
            case XML_MARSHALL_ERROR:
                log.warn("Unable to create the .dxml file. Are your file permissions correct? Aborting.");
                break;
            case FAILED:
                log.warn("Unable to create the necessary DXML file/folder resources at the provided location.");
                break;
            case INVALID_DXML_DATA:
            case BAD_PROJECT_PATH:
                log.warn("DXML project has corrupt data. Contact a developer, Aborting [Reason: {}].",
                        status.name());
                break;
            default:
                throw new DXMLException(
                        "DXML status for disk creation returned an unexpected enumeration. Contact a developer.");
            }
        } else {
            throw new DXMLException(
                    "DXML Wizard has not properly generated a proper file. Please contact a developer.");
        }
    } else {
        log.info("DXML project cancelled by user.");
    }
}

From source file:aajavafx.Schedule1Controller.java

@FXML
private void handleGetCustomersUnvisited(ActionEvent event) throws IOException {
    try {/*from w  w  w  .j a v  a2s  .  c o m*/
        getUnsignedCustomers();
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("UnsignedCustomers.fxml"));
        Parent root1 = (Parent) fxmlLoader.load();
        Stage stage = new Stage();
        stage.setScene(new Scene(root1));
        stage.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:slideshow.client.ui.ClientUIController.java

/**
 * Set ImageView to fullscreen//from   www  . j  a  va2s. co  m
 * @param event
 */
@FXML
void fullscreenClicked(ActionEvent event) {
    System.out.println("slideshow.client.ui.ClientUIController.fullscreenClicked");
    Stage stage = new Stage();
    stage.setTitle("Fullscreen");

    ImageView iv = this.photoImageView;
    Pane p = new Pane(iv);

    Scene scene = new Scene(p);

    stage.setScene(scene);

    stage.setWidth(100);
    stage.setHeight(200);
    stage.setFullScreen(true);

    stage.show();

}

From source file:com.neuronrobotics.bowlerstudio.MainController.java

/**
 * Initializes the controller class./*www. j a  v a  2s  .  co m*/
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    ScriptingEngine.setLoginManager(new IGitHubLoginManager() {

        @Override
        public String[] prompt(String username) {
            if (!loginWindowOpen && controller != null)
                controller.reset();
            loginWindowOpen = true;
            System.err.println("Calling login from BowlerStudio");
            // new RuntimeException().printStackTrace();
            FXMLLoader fxmlLoader = BowlerStudioResourceFactory.getGithubLogin();
            Parent root = fxmlLoader.getRoot();
            if (controller == null) {
                controller = fxmlLoader.getController();
                Platform.runLater(() -> {
                    controller.reset();
                    controller.getUsername().setText(username);
                    Stage stage = new Stage();
                    stage.setTitle("GitHub Login");
                    stage.initModality(Modality.APPLICATION_MODAL);
                    controller.setStage(stage, root);
                    stage.centerOnScreen();
                    stage.show();
                });
            }
            // setContent(root);
            while (!controller.isDone()) {
                ThreadUtil.wait(100);
            }
            String[] creds = controller.getCreds();
            loginWindowOpen = false;
            return creds;
        }
    });

    jfx3dmanager = new BowlerStudio3dEngine();

    setApplication(new BowlerStudioController(jfx3dmanager, this));
    Platform.runLater(() -> {
        editorContainer.getChildren().add(getApplication());
        AnchorPane.setTopAnchor(getApplication(), 0.0);
        AnchorPane.setRightAnchor(getApplication(), 0.0);
        AnchorPane.setLeftAnchor(getApplication(), 0.0);
        AnchorPane.setBottomAnchor(getApplication(), 0.0);

        subScene = jfx3dmanager.getSubScene();
        subScene.setFocusTraversable(false);
        subScene.setOnMouseEntered(mouseEvent -> {
            // System.err.println("3d window requesting focus");
            Scene topScene = BowlerStudio.getScene();
            normalKeyPessHandle = topScene.getOnKeyPressed();
            jfx3dmanager.handleKeyboard(topScene);
        });

        subScene.setOnMouseExited(mouseEvent -> {
            // System.err.println("3d window dropping focus");
            Scene topScene = BowlerStudio.getScene();
            topScene.setOnKeyPressed(normalKeyPessHandle);
        });

        subScene.widthProperty().bind(viewContainer.widthProperty());
        subScene.heightProperty().bind(viewContainer.heightProperty());
    });

    Platform.runLater(() -> {
        jfx3dControls.getChildren().add(jfx3dmanager.getControlsBox());
        viewContainer.getChildren().add(subScene);
    });

    System.out.println("Welcome to BowlerStudio!");
    new Thread() {
        public void run() {
            setName("Load Haar Thread");
            try {
                HaarFactory.getStream(null);
            } catch (Exception ex) {
            }
        }
    }.start();

    // getAddDefaultRightArm().setOnAction(event -> {
    //
    // application.onAddDefaultRightArm(event);
    // });
    // getAddVRCamera().setOnAction(event -> {
    // if(AddVRCamera.isSelected())
    // application.onAddVRCamera(event);
    // });

    FxTimer.runLater(Duration.ofMillis(100), () -> {
        if (ScriptingEngine.getLoginID() != null) {
            setToLoggedIn(ScriptingEngine.getLoginID());
        } else {
            setToLoggedOut();
        }

    });

    ScriptingEngine.addIGithubLoginListener(new IGithubLoginListener() {

        @Override
        public void onLogout(String oldUsername) {
            setToLoggedOut();
        }

        @Override
        public void onLogin(String newUsername) {
            setToLoggedIn(newUsername);

        }
    });

    cmdLine = new CommandLineWidget();

    Platform.runLater(() -> {
        // logView.resize(250, 300);
        // after connection manager set up, add scripting widget
        logViewRef = new TextArea();
        logViewRef.prefWidthProperty().bind(logView.widthProperty().divide(2));
        logViewRef.prefHeightProperty().bind(logView.heightProperty().subtract(40));
        VBox box = new VBox();
        box.getChildren().add(logViewRef);
        box.getChildren().add(cmdLine);
        VBox.setVgrow(logViewRef, Priority.ALWAYS);
        box.prefWidthProperty().bind(logView.widthProperty().subtract(10));

        logView.getChildren().addAll(box);
    });
}