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

The following examples show how to use javafx.stage.Stage#isShowing() . 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: WindowTitle.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public String getTitle() {
    String title = getTitle(window);
    ObservableList<Stage> windows = JavaCompatibility.getStages();
    String original = title;
    int index = 1;
    for (Stage w : windows) {
        if (w == window) {
            return title;
        }
        if (!w.isShowing()) {
            continue;
        }
        String wTitle = getTitle(w);
        if (original.equals(wTitle)) {
            title = original + "(" + index++ + ")";
        }
    }
    return title;
}
 
Example 2
Source File: JavaFXTargetLocator.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Stage[] getValidWindows() {
    ObservableList<Stage> stages = JavaCompatibility.getStages();
    List<Stage> valid = new ArrayList<Stage>();
    for (Stage window : stages) {
        if (window.isShowing()) {
            valid.add(window);
        }
    }
    return valid.toArray(new Stage[valid.size()]);
}
 
Example 3
Source File: DockItem.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Select this tab, i.e. raise it in case another tab is currently visible */
public void select()
{
    final DockPane pane = getDockPane();
    final Window window = pane.getScene().getWindow();
    if (window instanceof Stage)
    {
        Stage stage = (Stage) window;
        if (stage.isShowing())
            stage.toFront();
    }
    pane.getSelectionModel().select(this);
}
 
Example 4
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);

}