javafx.stage.Window.getWindows()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(223)

本文整理了Java中javafx.stage.Window.getWindows()方法的一些代码示例,展示了Window.getWindows()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getWindows()方法的具体详情如下:
包路径:javafx.stage.Window
类名称:Window
方法名:getWindows

Window.getWindows介绍

暂无

代码示例

代码示例来源:origin: org.testfx/testfx-internal-java9

public static List<Window> getWindows() {
  return new ArrayList<>(Window.getWindows());
}

代码示例来源:origin: org.tentackle/tentackle-fx

/**
 * Delivers a lis of all showing stages.
 *
 * @return the stages
 */
public ObservableList<Stage> getAllShowingStages() {
 ObservableList<Stage> stages = FXCollections.observableArrayList();
 Window.getWindows().forEach(w -> {
  if (w instanceof Stage) {
   stages.add((Stage) w);
  }
 });
 return stages;
}

代码示例来源:origin: org.controlsfx/controlsfx

/**
 * Will return a {@link Window} from an object if any can be found. {@code null}
 * value can be given, the program will then try to find the focused window
 * among those available.
 * 
 * @param owner the object whose window is to be found.
 * @return the window of the given object.
 */
public static Window getWindow(Object owner) throws IllegalArgumentException {
  if (owner == null) {
    // lets just get the focused stage and show the dialog in there
    List<Window> windows = Window.getWindows();
    for (Window window : windows) {
      if (window.isFocused() && !(window instanceof PopupWindow)) {
        return window;
      }
    }
    return null;
  } else if (owner instanceof Window) {
    return (Window) owner;
  } else if (owner instanceof Node) {
    return ((Node) owner).getScene().getWindow();
  } else {
    throw new IllegalArgumentException("Unknown owner: " + owner.getClass()); //$NON-NLS-1$
  }
}

相关文章