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

The following examples show how to use javafx.stage.Stage#setX() . 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: ReceptionistController.java    From HealthPlus with Apache License 2.0 8 votes vote down vote up
@FXML
public void showAppointmentSuccessIndicator(String patientId, String consult, String appDate, String appId)
{
    Stage stage= new Stage();
    AppointmentSuccessController success = new AppointmentSuccessController();
    
    success.fillAppointmentData(patientId,consult,appDate,appId);
    
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example 2
Source File: StageControllerImpl.java    From scenic-view with GNU General Public License v3.0 6 votes vote down vote up
public void placeStage(final Stage stage) {
    if (targetWindow != null) {
        stage.setX(targetWindow.getX() + targetWindow.getWidth());
        stage.setY(targetWindow.getY());
        try {
            // Prevents putting the stage out of the screen
            final Screen primary = Screen.getPrimary();
            if (primary != null) {
                final Rectangle2D rect = primary.getVisualBounds();
                if (stage.getX() + stage.getWidth() > rect.getMaxX()) {
                    stage.setX(rect.getMaxX() - stage.getWidth());
                }
                if (stage.getY() + stage.getHeight() > rect.getMaxY()) {
                    stage.setX(rect.getMaxY() - stage.getHeight());
                }
            }
        } catch (final Exception e) {
            ExceptionLogger.submitException(e);
        }
    }
}
 
Example 3
Source File: AdminController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML
private void viewCashierAccounts()
{
    Stage stage = new Stage();
    UserAccountController userAccounts = new UserAccountController("cashier",admin);
    
    ArrayList<ArrayList<String>> data = admin.getUserInfo("cashier");
    System.out.println(data);
    userAccounts.fillUserDetail(data);
    
    Scene scene = new Scene(userAccounts);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show(); 
}
 
Example 4
Source File: AdminController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML
private void viewOnlineAccounts()
{
    Stage stage = new Stage();
    UserAccountController userAccounts = new UserAccountController("",admin);
    
    ArrayList<ArrayList<String>> data = admin.getOnlineInfo();
    userAccounts.fillUserDetail(data);
    
    Scene scene = new Scene(userAccounts);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show(); 
}
 
Example 5
Source File: LoginController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
public void loadLabAssistant(String username)
{
    Stage stage = new Stage();
    LabAssistantController lab = new LabAssistantController(username);
    lab.loadProfileData(); 
    lab.fillPieChart();
    lab.setAppointments();
    lab.fillLabAppiontments();
    lab.addFocusListener();
    lab.setPaceholders();
    lab.fillTodayAppointments();
    
    stage.setScene(new Scene(lab));
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    stage.initStyle(StageStyle.UNDECORATED);
    stage.show();
}
 
Example 6
Source File: HttpDownApplication.java    From proxyee-down with Apache License 2.0 6 votes vote down vote up
@Override
  public void start(Stage stage) throws Exception {
    initHandle();
    this.stage = stage;
    Platform.setImplicitExit(false);
    SwingUtilities.invokeLater(this::addTray);
    stage.setTitle("proxyee-down-" + version);
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    stage.getIcons().add(new Image(
        Thread.currentThread().getContextClassLoader().getResourceAsStream("favicon.png")));
    stage.setOnCloseRequest(event -> {
      event.consume();
      close();
    });
    beforeOpen();
//    open();
    afterOpen();
  }
 
Example 7
Source File: ReceptionistController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML
public void showSuccessIndicator()
{
    Stage stage= new Stage();
    SuccessIndicatorController success = new SuccessIndicatorController();
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example 8
Source File: AdminController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML private void searchUser()
{
    
    String userid = userIDlbl.getText();
    
    if (!userid.equals(""))
    {    
        Stage stage= new Stage();
        SysUserController user = new SysUserController(this,userid);
        user.load();
        Scene scene = new Scene(user);
        stage.setScene(scene);

        Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
        //set Stage boundaries to visible bounds of the main screen
        stage.setX(primaryScreenBounds.getMinX());
        stage.setY(primaryScreenBounds.getMinY());
        stage.setWidth(primaryScreenBounds.getWidth());
        stage.setHeight(primaryScreenBounds.getHeight());

        stage.initStyle(StageStyle.UNDECORATED);
        scene.setFill(null);
        stage.initStyle(StageStyle.TRANSPARENT);
        stage.show();   
    }    
}
 
Example 9
Source File: LabAssistantController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
@FXML
public void showSuccessIndicator()
{
    Stage stage= new Stage();
    SuccessIndicatorController success = new SuccessIndicatorController();
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example 10
Source File: BisqApp.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void showDebugWindow(Scene scene, Injector injector) {
    ViewLoader viewLoader = injector.getInstance(ViewLoader.class);
    View debugView = viewLoader.load(DebugView.class);
    Parent parent = (Parent) debugView.getRoot();
    Stage stage = new Stage();
    stage.setScene(new Scene(parent));
    stage.setTitle("Debug window"); // Don't translate, just for dev
    stage.initModality(Modality.NONE);
    stage.initStyle(StageStyle.UTILITY);
    stage.initOwner(scene.getWindow());
    stage.setX(this.stage.getX() + this.stage.getWidth() + 10);
    stage.setY(this.stage.getY());
    stage.show();
}
 
Example 11
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the stage properly on the monitor where the mouse pointer is
 * 
 * @param stage
 */
public void setMonitor(Stage stage) {
	// TODO: how to run on the "Active monitor" as chosen by user ?
	// Note : "Active monitor is defined by whichever computer screen the mouse
	// pointer is or where the command console that starts mars-sim.
	// By default, it runs on the primary monitor (aka monitor 0 as reported by
	// windows os only.
	// see
	// http://stackoverflow.com/questions/25714573/open-javafx-application-on-active-screen-or-monitor-in-multi-screen-setup/25714762#25714762
	StartUpLocation startUpLoc = null;

	if (rootStackPane == null) {
		StackPane pane = new StackPane();
		pane.setPrefHeight(sceneWidth.get());
		pane.setPrefWidth(sceneHeight.get());
		// pane.prefHeightProperty().bind(scene.heightProperty());
		// pane.prefWidthProperty().bind(scene.widthProperty());
		startUpLoc = new StartUpLocation(pane.getPrefWidth(), pane.getPrefHeight());
	} else {
		startUpLoc = new StartUpLocation(rootStackPane.getWidth(), rootStackPane.getHeight());
	}

	double xPos = startUpLoc.getXPos();
	double yPos = startUpLoc.getYPos();
	// Set Only if X and Y are not zero and were computed correctly
	// if (xPos != 0 && yPos != 0) {
	stage.setX(xPos+1);
	stage.setY(yPos+1);
	// }

	// stage.centerOnScreen(); // this will cause the stage to be pinned slight
	// upward.
}
 
Example 12
Source File: Pikatimer.java    From pikatimer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    
    //stash the primaryStage in the event object
    mainStage=primaryStage;
    
    primaryStage.setTitle("PikaTimer " + VERSION);
    
    mainStage.setWidth(600);
    mainStage.setHeight(400);
    
    
    Pane myPane = (Pane)FXMLLoader.load(getClass().getResource("FXMLopenEvent.fxml"));
    Scene myScene = new Scene(myPane);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();  
  
    //set Stage boundaries so that the main screen is centered.                
    primaryStage.setX((primaryScreenBounds.getWidth() - primaryStage.getWidth())/2);  
    primaryStage.setY((primaryScreenBounds.getHeight() - primaryStage.getHeight())/2);  
 
    // F11 to toggle fullscreen mode
    myScene.getAccelerators().put(new KeyCodeCombination(KeyCode.F11), () -> {
        mainStage.setFullScreen(mainStage.fullScreenProperty().not().get());
    });
    
    // Icons
    String[] sizes = {"256","128","64","48","32"};
    for(String s: sizes){
        primaryStage.getIcons().add(new Image("resources/icons/Pika_"+s+".ico"));
        primaryStage.getIcons().add(new Image("resources/icons/Pika_"+s+".png"));
    }
    
    
    primaryStage.setScene(myScene);
    primaryStage.show();
    
    System.out.println("Exiting Pikatimer.start()");
}
 
Example 13
Source File: StageUtils.java    From xJavaFxTool-spring with Apache License 2.0 5 votes vote down vote up
public static void loadPrimaryStageBound(Stage stage) {
    try {
        if (!Config.getBoolean(Keys.RememberWindowLocation, true)) {
            return;
        }

        double left = Config.getDouble(Keys.MainWindowLeft, -1);
        double top = Config.getDouble(Keys.MainWindowTop, -1);
        double width = Config.getDouble(Keys.MainWindowWidth, -1);
        double height = Config.getDouble(Keys.MainWindowHeight, -1);

        if (left > 0) {
            stage.setX(left);
        }
        if (top > 0) {
            stage.setY(top);
        }
        if (width > 0) {
            stage.setWidth(width);
        }
        if (height > 0) {
            stage.setHeight(height);
        }
    } catch (Exception e) {
        log.error("初始化界面位置失败:", e);
    }
}
 
Example 14
Source File: DockingDemo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void start(final Stage stage)
{
    // Add dock items to the original stage
    final DockItem tab1 = new DockItem("Tab 1");
    final BorderPane layout = new BorderPane();
    layout.setTop(new Label("Top"));
    layout.setCenter(new Label("Tab that indicates resize behavior"));
    layout.setBottom(new Label("Bottom"));
    tab1.setContent(layout);

    final DockItem tab2 = new DockItem("Tab 2");
    tab2.setContent(new Rectangle(500, 500, Color.RED));

    // The DockPane is added to a stage by 'configuring' it.
    // Initial tabs can be provided right away
    DockPane tabs = DockStage.configureStage(stage, tab1, tab2);
    stage.setX(100);

    // .. or tabs are added later
    final DockItem tab3 = new DockItem("Tab 3");
    tab3.setContent(new Rectangle(500, 500, Color.GRAY));
    tabs.addTab(tab3);

    // Create another stage with more dock items
    final DockItem tab4 = new DockItem("Tab 4");
    tab4.setContent(new Rectangle(500, 500, Color.YELLOW));

    final DockItem tab5 = new DockItem("Tab 5");
    tab5.setContent(new Rectangle(500, 500, Color.BISQUE));

    final Stage other = new Stage();
    DockStage.configureStage(other, tab4, tab5);
    other.setX(600);

    stage.show();
    other.show();
}
 
Example 15
Source File: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static void setMaximized(Stage stage, boolean max) {
    stage.setMaximized(max);
    if (max) {
        Rectangle2D primaryScreenBounds = getScreen();
        stage.setX(primaryScreenBounds.getMinX());
        stage.setY(primaryScreenBounds.getMinY());
        stage.setWidth(primaryScreenBounds.getWidth());
        stage.setHeight(primaryScreenBounds.getHeight());
    }
}
 
Example 16
Source File: MainApp.java    From Corendon-LostLuggage with MIT License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {

    //Method to set the db property
    setDatabase("corendonlostluggage", "root", "admin");
            
    //set root
    root = FXMLLoader.load(getClass().getResource("/fxml/MainView.fxml"));
    Scene mainScene = new Scene(root);

    checkLoggedInStatus(currentUser);

    mainScene.getStylesheets().add("/styles/Styles.css");

    stage.setTitle("Corendon Lost Luggage");
    stage.setScene(mainScene);

    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());

    stage.setMinWidth(1000);
    stage.setMinHeight(700);

    Image logo = new Image("Images/Stage logo.png");
    //Image applicationIcon = new Image(getClass().getResourceAsStream("Images/Logo.png"));
    stage.getIcons().add(logo);

    stage.show();

    //Set the mainstage as a property
    MainApp.mainStage = stage;

}
 
Example 17
Source File: UMLEditor.java    From JetUML with GNU General Public License v3.0 5 votes vote down vote up
private void setStageBoundaries(Stage pStage)
{
	Rectangle defaultStageBounds = GuiUtils.defaultStageBounds();
	pStage.setX(defaultStageBounds.getX());
	pStage.setY(defaultStageBounds.getY());
	pStage.setWidth(defaultStageBounds.getWidth());
	pStage.setHeight(defaultStageBounds.getHeight());
}
 
Example 18
Source File: XdatEditor.java    From xdat_editor with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    this.stage = primaryStage;

    FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml"), interfaceResources);
    loader.setClassLoader(getClass().getClassLoader());
    loader.setControllerFactory(param -> new Controller(XdatEditor.this));
    Parent root = loader.load();
    controller = loader.getController();

    primaryStage.setTitle("XDAT Editor");
    primaryStage.setScene(new Scene(root));
    primaryStage.setWidth(Double.parseDouble(windowPrefs().get("width", String.valueOf(primaryStage.getWidth()))));
    primaryStage.setHeight(Double.parseDouble(windowPrefs().get("height", String.valueOf(primaryStage.getHeight()))));
    if (windowPrefs().getBoolean("maximized", primaryStage.isMaximized())) {
        primaryStage.setMaximized(true);
    } else {
        Rectangle2D bounds = new Rectangle2D(
                Double.parseDouble(windowPrefs().get("x", String.valueOf(primaryStage.getX()))),
                Double.parseDouble(windowPrefs().get("y", String.valueOf(primaryStage.getY()))),
                primaryStage.getWidth(),
                primaryStage.getHeight());
        if (Screen.getScreens()
                .stream()
                .map(Screen::getVisualBounds)
                .anyMatch(r -> r.intersects(bounds))) {
            primaryStage.setX(bounds.getMinX());
            primaryStage.setY(bounds.getMinY());
        }
    }
    primaryStage.show();

    Platform.runLater(() -> {
        InvalidationListener listener = observable -> {
            if (primaryStage.isMaximized()) {
                windowPrefs().putBoolean("maximized", true);
            } else {
                windowPrefs().putBoolean("maximized", false);
                windowPrefs().put("x", String.valueOf(Math.round(primaryStage.getX())));
                windowPrefs().put("y", String.valueOf(Math.round(primaryStage.getY())));
                windowPrefs().put("width", String.valueOf(Math.round(primaryStage.getWidth())));
                windowPrefs().put("height", String.valueOf(Math.round(primaryStage.getHeight())));
            }
        };
        primaryStage.xProperty().addListener(listener);
        primaryStage.yProperty().addListener(listener);
        primaryStage.widthProperty().addListener(listener);
        primaryStage.heightProperty().addListener(listener);
    });
    Platform.runLater(this::postShow);
}
 
Example 19
Source File: LabAssistantController.java    From HealthPlus with Apache License 2.0 4 votes vote down vote up
public void showReport(String reportID)
{

        String type = "";
        ArrayList<ArrayList<String>> data = null;
        
        if ( reportID.substring(0,2).equals("ur") ) {
        
            data = lab.getUrineFullReport(reportID);
            type = "ur";
            
        } else if ( reportID.substring(0,2).equals("li") ) {
            
            data = lab.getLipidTestReport(reportID);
            type = "li";
            
        } else if ( reportID.substring(0,2).equals("bg") ) {
        
            data = lab.getBloodGroupingRh(reportID);
            type = "bg";
            
        } else if ( reportID.substring(0,3).equals("cbc") ) {
        
            data = lab.getCompleteBloodCount(reportID);
            type = "cbc";
            
        } else if ( reportID.substring(0,2).equals("lv") ) {
        
            data = lab.getLiverFunctionTest(reportID);
            type = "lv";
            
        } else if ( reportID.substring(0,2).equals("re") ) {
        
            data = lab.getRenalFunctionTest(reportID);
            type = "re";
            
        } else if ( reportID.substring(0,4).equals("scpt") ) {
        
            data = lab.getSeriumCreatinePhosphokinaseTotal(reportID);
            type = "scpt";
            
        } else if ( reportID.substring(0,3).equals("scp") ) {
        
            data = lab.getSeriumCreatinePhosphokinase(reportID);
            type = "scp";
            
        }     
        
        if (data.size() > 1){
            LabReportPreviewController preview = new LabReportPreviewController(lab);
            preview.setData(data,type);

            Stage stage = new Stage();
            Scene scene = new Scene(preview);
            stage.setScene(scene);

            Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
            //set Stage boundaries to visible bounds of the main screen
            stage.setX(primaryScreenBounds.getMinX());
            stage.setY(primaryScreenBounds.getMinY());
            stage.setWidth(primaryScreenBounds.getWidth());
            stage.setHeight(primaryScreenBounds.getHeight());
            stage.initStyle(StageStyle.UNDECORATED);
            scene.setFill(null);
            stage.initStyle(StageStyle.TRANSPARENT);
            stage.show(); 
        } else {
            
            //showErrorPopup("No Report", appointmentIDtext);
        }

}
 
Example 20
Source File: WindowSettingsParameter.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set window size and position according to the values in this instance
 */
public void applySettingsToWindow(@Nonnull final Stage stage) {

  logger.finest("Setting window " + stage.getTitle() + " position " + posX + ":" + posY
      + " and size " + width + "x" + height);
  if (posX != null)
    stage.setX(posX);
  if (posY != null)
    stage.setX(posY);
  if (width != null)
    stage.setWidth(width);
  if (height != null)
    stage.setHeight(height);

  if ((isMaximized != null) && isMaximized) {
    logger.finest("Setting window " + stage.getTitle() + " to maximized");
    stage.setMaximized(true);
  }

  // when still outside of screen
  // e.g. changing from 2 screens to one
  if (stage.isShowing() && !isOnScreen(stage)) {
    // Maximize on screen 1
    logger.finest(
        "Window " + stage.getTitle() + " is not on screen, setting to maximized on screen 1");
    stage.setX(0.0);
    stage.setY(0.0);
    stage.sizeToScene();
    stage.setMaximized(true);
  }

  ChangeListener<Number> stageListener = (observable, oldValue, newValue) -> {
    posX = stage.getX();
    posY = stage.getY();
    width = stage.getWidth();
    height = stage.getHeight();
  };
  stage.widthProperty().addListener(stageListener);
  stage.heightProperty().addListener(stageListener);
  stage.xProperty().addListener(stageListener);
  stage.yProperty().addListener(stageListener);

}