io.reactivex.rxjavafx.observables.JavaFxObservable#javafx.stage.WindowEvent源码实例Demo

下面列出了io.reactivex.rxjavafx.observables.JavaFxObservable#javafx.stage.WindowEvent 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pmd-designer   文件: PopOverWrapper.java
/**
 * This is a weird hack to preload the FXML and CSS, so that the
 * first opening of the popover doesn't look completely broken
 * (twitching and obviously being restyled).
 *
 * <p>We show the popover briefly with opacity 0, just the time for its
 * content graph to load. When hidden the opacity is reset to 1.
 */
public void doFirstLoad(Stage stage) {
    myPopover.ifPresent(pop -> {
        pop.setOpacity(0);
        pop.setAnimated(false);
        pop.show(stage, 40000, 40000);

        EventStreams.eventsOf(pop, WindowEvent.WINDOW_HIDDEN)
                    .subscribeForOne(e -> pop.setOpacity(1));

        Platform.runLater(() -> {
            pop.hide();
            pop.setAnimated(true);
        });
    });
}
 
源代码2 项目: scenic-view   文件: HelpBox.java
public HelpBox(final String title, final String url, final double x, final double y) {
    final BorderPane pane = new BorderPane();
    pane.setId(StageController.FX_CONNECTOR_BASE_ID + "HelpBox");
    pane.setPrefWidth(SCENE_WIDTH);
    pane.setPrefHeight(SCENE_HEIGHT);
    final ProgressWebView wview = new ProgressWebView();
    wview.setPrefHeight(SCENE_HEIGHT);
    wview.setPrefWidth(SCENE_WIDTH);
    wview.doLoad(url);
    pane.setCenter(wview);
    final Scene scene = new Scene(pane, SCENE_WIDTH, SCENE_HEIGHT); 
    stage = new Stage();
    stage.setTitle(title);
    stage.setScene(scene);
    stage.getIcons().add(HELP_ICON);
    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {

        @Override public void handle(final WindowEvent arg0) {
            DisplayUtils.showWebView(false);
        }
    });
    stage.show();
}
 
源代码3 项目: oim-fx   文件: TrayDemo.java
@Override
public void start(final Stage stage) throws Exception {
	enableTray(stage);

	GridPane grid = new GridPane();
	grid.setAlignment(Pos.CENTER);
	grid.setHgap(20);
	grid.setVgap(20);
	grid.setGridLinesVisible(true);
	grid.setPadding(new Insets(25, 25, 25, 25));

	Button b1 = new Button("测试1");
	Button b2 = new Button("测试2");
	grid.add(b1, 0, 0);
	grid.add(b2, 1, 1);

	Scene scene = new Scene(grid, 800, 600);
	stage.setScene(scene);
	stage.setOnCloseRequest(new EventHandler<WindowEvent>() {

		@Override
		public void handle(WindowEvent arg0) {
			stage.hide();
		}
	});
}
 
源代码4 项目: oim-fx   文件: HideTaskBar.java
@Override
public void start(final Stage stage) throws Exception {
	stage.initStyle(StageStyle.UTILITY);
	stage.setScene(new Scene(new Group(), 100, 100));
	stage.setX(0);
	stage.setY(Screen.getPrimary().getBounds().getHeight() + 100);
	stage.show();

	Stage app = new Stage();
	app.setScene(new Scene(new Group(), 300, 200));
	app.setTitle("JavaFX隐藏任务栏");
	app.initOwner(stage);
	app.initModality(Modality.APPLICATION_MODAL);
	app.setOnCloseRequest(new EventHandler<WindowEvent>() {
		@Override
		public void handle(WindowEvent event) {
			event.consume();
			stage.close();
		}
	});

	app.show();
}
 
源代码5 项目: PreferencesFX   文件: PreferencesFxPresenter.java
/**
 * {@inheritDoc}
 */
@Override
public void setupEventHandlers() {
  // As the scene is null here, listen to scene changes and make sure
  // that when the window is closed, the settings are saved beforehand.

  // NOTE: this only applies to the main stage. When opening PreferencesFX as a Node in a new
  // window, the implementor needs to take care that Settings are saved by themself!
  // This is intentional by design to ensure that if the implementor wants to make their own
  // PreferencesFX dialog to not override settings in case they are discarded.
  preferencesFxView.sceneProperty().addListener((observable, oldScene, newScene) -> {
    LOGGER.trace("new Scene: " + newScene);
    if (newScene != null && newScene.getWindow() != null) {
      LOGGER.trace("addEventHandler on Window close request to save settings");
      newScene.getWindow().addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, event -> {
        LOGGER.trace("saveSettings because of WINDOW_CLOSE_REQUEST");
        model.saveSettings();
      });
    }
  });
}
 
源代码6 项目: OEE-Designer   文件: OpcDaTrendController.java
public SplitPane initializeTrend() throws Exception {
	if (trendChartController == null) {
		// Load the fxml file and create the anchor pane
		FXMLLoader loader = FXMLLoaderFactory.trendChartLoader();
		spTrendChart = (SplitPane) loader.getRoot();

		trendChartController = loader.getController();
		trendChartController.initialize(getApp());

		// data provider
		trendChartController.setProvider(this);

		setImages();

		getDialogStage().setOnCloseRequest((WindowEvent event1) -> {
			onDisconnect();
		});
	}
	return spTrendChart;
}
 
源代码7 项目: Project-16x16   文件: SideScroller.java
/**
 * Called by Processing after settings().
 */
@Override
protected PSurface initSurface() {
	surface = (PSurfaceFX) super.initSurface();
	canvas = (Canvas) surface.getNative();
	canvas.widthProperty().unbind(); // used for scaling
	canvas.heightProperty().unbind(); // used for scaling
	scene = canvas.getScene();
	stage = (Stage) scene.getWindow();
	stage.setTitle("Project-16x16");
	stage.setResizable(false); // prevent abitrary user resize
	stage.setFullScreenExitHint(""); // disable fullscreen toggle hint
	stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); // prevent ESC toggling fullscreen
	scene.getWindow().addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, this::closeWindowEvent);
	return surface;
}
 
源代码8 项目: Rails   文件: FXStockChartWindow.java
@Override
public void start(Stage primaryStage) {
    // set the stock-chart window to hide, if it has been closed
    Platform.setImplicitExit(false);

    Scene scene = new Scene(new FXStockChart(gameUIManager));

    primaryStage.setTitle("Rails: Stock Chart");
    primaryStage.setScene(scene);

    // uncheck market checkbox in the menu if the stock-chart has been closed
    primaryStage.addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, event -> {
        gameUIManager.uncheckMenuItemBox(StatusWindow.MARKET_CMD);
    });

    // TODO: save relocation and resizing information of the window

    stage = primaryStage;
}
 
源代码9 项目: xJavaFxTool-spring   文件: Main.java
@Override
public void beforeInitialView(Stage stage, ConfigurableApplicationContext ctx) {
    super.beforeInitialView(stage, ctx);
    Scene scene = JavaFxViewUtil.getJFXDecoratorScene(stage, "", null, new AnchorPane());
    stage.setScene(scene);
    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent event) {
            if (AlertUtil.showConfirmAlert("确定要退出吗?")) {
                System.exit(0);
            } else {
                event.consume();
            }
        }
    });
    GUIState.setScene(scene);
    Platform.runLater(() -> {
        StageUtils.updateStageStyle(GUIState.getStage());
    });
}
 
源代码10 项目: PeerWasp   文件: ActivityStage.java
private void load() {
	try {

		FXMLLoader loader = fxmlLoaderProvider.create(ViewNames.ACTIVITY_VIEW);
		Parent root = loader.load();
		Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT);
		stage = new Stage();
		stage.setTitle(WINDOW_TITLE);

		Collection<Image> icons = IconUtils.createWindowIcons();
		stage.getIcons().addAll(icons);

		stage.setScene(scene);
		stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, new WindowCloseRequestEventHandler());

	} catch (IOException e) {
		logger.error("Could not load activity stage: {}", e.getMessage(), e);
	}
}
 
源代码11 项目: PeerWasp   文件: SettingsStage.java
private void load() {
	try {
		Preconditions.checkNotNull(appContext.getCurrentClientContext(), "ClientContext must not be null.");

		// important: use injector for client here because of client specific instances.
		FXMLLoader loader = fxmlLoaderProvider.create(ViewNames.SETTINGS_MAIN, appContext.getCurrentClientContext().getInjector());
		Parent root = loader.load();
		Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT);
		stage = new Stage();
		stage.setTitle(WINDOW_TITLE);

		Collection<Image> icons = IconUtils.createWindowIcons();
		stage.getIcons().addAll(icons);

		stage.setScene(scene);
		stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, new WindowCloseRequestEventHandler());

	} catch (IOException e) {
		logger.error("Could not load settings stage: {}", e.getMessage(), e);
	}
}
 
@FXML
private void activityLogButtonAction(ActionEvent event)
{
    mainTopAnchorPane.setEffect(new BoxBlur());
    passwordStage = new Stage();
    passwordStage.setOnCloseRequest(new EventHandler<WindowEvent>()
    {
        @Override
        public void handle(WindowEvent t)
        {
            mainTopAnchorPane.effectProperty().setValue(null);
        }
    });
    passwordStage.setTitle("Activity Log");
    passwordStage.initModality(Modality.APPLICATION_MODAL);
    passwordStage.initStyle(StageStyle.UTILITY);
    passwordStage.setResizable(false);
    try
    {
        Parent passwordParent = FXMLLoader.load(getClass().getResource("activityLog.fxml"));
        passwordStage.setScene(new Scene(passwordParent));
        passwordStage.show();
    } catch (IOException ex)
    {
    }
}
 
@FXML
private void viewPayBillAction(ActionEvent event)
{
    MainProgramSceneController.mainTopAnchorPane.setEffect(new BoxBlur());
    billStage = new Stage();
    billStage.setOnCloseRequest(new EventHandler<WindowEvent>()
    {
        @Override
        public void handle(WindowEvent t)
        {
            MainProgramSceneController.mainTopAnchorPane.effectProperty().setValue(null);
        }
    });
    billStage.setTitle("View And Pay Due Bills");
    billStage.initModality(Modality.APPLICATION_MODAL);
    billStage.initStyle(StageStyle.UTILITY);
    billStage.setResizable(false);
    try
    {
        Parent passwordParent = FXMLLoader.load(getClass().getResource("viewPayBill.fxml"));
        billStage.setScene(new Scene(passwordParent));
        billStage.show();
    } catch (IOException ex)
    {
    }
}
 
源代码14 项目: pattypan   文件: Main.java
@Override
public void start(Stage stage) {
  Image logo = new Image(getClass().getResourceAsStream("/pattypan/resources/logo.png"));

  Scene scene = new Scene(new StartPane(stage), Settings.getSettingInt("windowWidth"), Settings.getSettingInt("windowHeight"));
  stage.setResizable(true);
  stage.setTitle("pattypan " + Settings.VERSION);
  stage.getIcons().add(logo);
  stage.setScene(scene);
  stage.show();

  stage.setOnCloseRequest((WindowEvent we) -> {
    Settings.setSetting("windowWidth", (int) scene.getWidth() + "");
    Settings.setSetting("windowHeight", (int) scene.getHeight() + "");
    Settings.setSetting("version", Settings.VERSION);
    Settings.saveProperties();
  });
}
 
源代码15 项目: VocabHunter   文件: ExitRequestHandler.java
private boolean processCloseRequest(final WindowEvent e) {
    boolean isContinue = guiFileHandler.unsavedChangesCheck();

    if (isContinue) {
        WindowSettings windowSettings = new WindowSettings();

        windowSettings.setX(stage.getX());
        windowSettings.setY(stage.getY());
        windowSettings.setWidth(stage.getWidth());
        windowSettings.setHeight(stage.getHeight());
        model.getSessionModel().ifPresent(s -> saveSplitPositions(windowSettings, s));

        settingsManager.setWindowSettings(windowSettings);
    } else {
        e.consume();
    }

    return isContinue;
}
 
/**
 * Initialize current stage
 */
public void init() {
    currentStage = (Stage) profileViewWrapper.getScene().getWindow();

    currentStage.setOnShown(new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent event) {
            currentStage.focusedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
                if (newValue && tableView.isStreamEditingWindowOpen()) {
                    Util.optimizeMemory();
                    loadStreamTable();
                    tableView.setStreamEditingWindowOpen(false);
                }
            });
        }
    });
}
 
源代码17 项目: FakeImageDetection   文件: SingleImageCheck.java
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/resources/fxml/singleimage.fxml"));

    Scene scene = new Scene(root);

    stage.resizableProperty().setValue(false);
    stage.setTitle("Single Image Checker");
    stage.setScene(scene);
    stage.show();
    CommonUtil.attachIcon(stage);

    stage.setOnCloseRequest((WindowEvent event) -> {
        System.exit(0);
    });
}
 
源代码18 项目: Lipi   文件: HugoPane.java
@FXML
private void onLiveBlogServerToggle() {
    toggleLiveBlogServer();
    updateBlogServerToggleButton();

    TimedUpdaterUtil.callAfter(new CallbackVisitor() {
        @Override
        public void call() {
            if (!openBlogInBrowserButton.isDisabled() && !liveServerRunning) {
                updateBlogServerToggleButton();
                ExceptionAlerter.showException(new Exception("Hugo faced a catastrophic error \n" +
                        hugoServer.getHugoOut()));
            }
        }
    });

    this.getScene().getWindow().setOnCloseRequest(new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent event) {
            stopLiveBlogServer();
        }
    });
}
 
源代码19 项目: OpenLabeler   文件: OpenLabelerController.java
public void handleWindowEvent(WindowEvent event) {
    if (event.getEventType() == WindowEvent.WINDOW_SHOWN) {
        // Initial focus
        tagBoard.requestFocus();

        // Open last media file/folder
        if (Settings.isOpenLastMedia() && Settings.recentFilesProperty.size() > 0) {
            File fileOrDir = new File(Settings.recentFilesProperty.get(0));
            openFileOrDir(fileOrDir);
        }
    }
}
 
源代码20 项目: pmd-designer   文件: SyntaxHighlightingCodeArea.java
public SyntaxHighlightingCodeArea() {
    // captured in the closure
    final EventHandler<WindowEvent> autoCloseHandler = e -> syntaxAutoRefresh.ifPresent(Subscription::unsubscribe);

    // handles auto shutdown of executor services
    // by attaching a handler to the stage responsible for the control
    Val.wrap(sceneProperty())
       .filter(Objects::nonNull)
       .flatMap(Scene::windowProperty)
       .values()
       .filter(Objects::nonNull)
        .subscribe(c -> c.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, autoCloseHandler));


    // prevent ALT from focusing menu
    addEventFilter(KeyEvent.KEY_PRESSED, e -> {
        if (e.isAltDown()) {
            e.consume();
        }
    });


    // Make TAB 4 spaces
    InputMap<KeyEvent> im = InputMap.consume(
        EventPattern.keyPressed(KeyCode.TAB),
        e -> replaceSelection("    ")
    );

    Nodes.addInputMap(this, im);
}
 
源代码21 项目: cssfx   文件: CSSFXTesterApp.java
@Override
public void start(Stage stage) throws Exception {
    fillStage(stage);
    stage.show();
    Runnable cssfxCloseAction = CSSFX.start();

    stage.getScene().getWindow()
            .addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, (event) -> cssfxCloseAction.run());
}
 
源代码22 项目: chart-fx   文件: WaterfallPerformanceSample.java
private void closeDemo(final WindowEvent evt) {
    if (evt.getEventType().equals(WindowEvent.WINDOW_CLOSE_REQUEST) && LOGGER.isInfoEnabled()) {
        LOGGER.atInfo().log("requested demo to shut down");
    }
    if (timer != null) {
        timer.cancel();
        timer = null; // NOPMD
        dataSet.stop();
    }
    Platform.exit();
}
 
源代码23 项目: scenic-view   文件: ScenicViewGui.java
public static void show(final ScenicViewGui scenicview, final Stage stage) {
    final Scene scene = new Scene(scenicview.rootBorderPane);
    scene.getStylesheets().addAll(STYLESHEETS);
    stage.setScene(scene);
    stage.getIcons().add(APP_ICON);
    if (scenicview.activeStage != null && scenicview.activeStage instanceof StageControllerImpl)
        ((StageControllerImpl) scenicview.activeStage).placeStage(stage);

    stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, event -> {
        Runtime.getRuntime().removeShutdownHook(scenicview.shutdownHook);
        scenicview.close();
    });
    stage.show();
}
 
源代码24 项目: WorkbenchFX   文件: WorkbenchTest.java
/**
 * Internal utility method for testing.
 * Simulates closing the stage, which fires a close request to test logic
 * inside of {@link Stage#setOnCloseRequest(EventHandler)}.
 * Using {@link FxRobot#closeCurrentWindow()} would be better, but it only works on Windows
 * because of its implementation, so this approach was chosen as a workaround.
 * @see <a href="https://github.com/TestFX/TestFX/issues/447">
 * closeCurrentWindow() doesn't work headless</a>
 */
private void closeStage() {
  Stage stage = ((Stage) workbench.getScene().getWindow());
  stage.fireEvent(
      new WindowEvent(
          stage,
          WindowEvent.WINDOW_CLOSE_REQUEST
      )
  );
}
 
源代码25 项目: DevToolBox   文件: Loading.java
public void startMainApp(Stage ms) {
    try {
        long time = System.currentTimeMillis();
        Stage stage = new Stage();
        stage.setTitle(Undecorator.LOC.getString("AppName") + " " + Undecorator.LOC.getString("Version") + " 版本号:" + Undecorator.LOC.getString("VersionCode"));
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/main.fxml"));
        Region root = (Region) fxmlLoader.load();
        final UndecoratorScene undecoratorScene = new UndecoratorScene(stage, root);
        stage.setOnCloseRequest((WindowEvent we) -> {
            we.consume();
            undecoratorScene.setFadeOutTransition();
        });
        undecoratorScene.getStylesheets().add("/styles/main.css");
        stage.setScene(undecoratorScene);
        stage.toFront();
        stage.getIcons().add(new Image(getClass().getResourceAsStream("/skin/icon.png")));
        stage.setOnShown((event) -> {
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    Platform.runLater(() -> {
                        ms.close();
                    });
                }
            }, 1000);
        });
        stage.show();
        ApplicationStageManager.putStageAndController(ApplicationStageManager.StateAndController.MAIN, stage, fxmlLoader.getController());
        LOGGER.info("主页面加载耗时:" + (System.currentTimeMillis() - time) + "毫秒");
    } catch (IOException ex) {
        LOGGER.error("启动主程序异常", ex);
    }
}
 
源代码26 项目: DevToolBox   文件: UndecoratorController.java
public void close() {
    final Stage stage = undecorator.getStage();
    Platform.runLater(() -> {
        stage.fireEvent(new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST));
    });

}
 
源代码27 项目: Project-16x16   文件: SideScroller.java
/**
 * Passes JavaFX window closed call to game.
 * 
 * @param event
 */
private void closeWindowEvent(WindowEvent event) {
	try {
		Audio.exit();
		game.exit();
	} finally {
		stage.close();
	}
}
 
源代码28 项目: RadialFx   文件: RadialMenuItemDemo.java
@Override
   public void start(final Stage stage) throws Exception {
final RadialMenuItem item = RadialMenuItemBuilder.create().build();
item.setTranslateX(400);
item.setTranslateY(300);

final DemoUtil demoUtil = new DemoUtil();
demoUtil.addAngleControl("StartAngle", item.startAngleProperty());
demoUtil.addAngleControl("Length", item.lengthProperty());
demoUtil.addRadiusControl("Inner Radius", item.innerRadiusProperty());
demoUtil.addRadiusControl("Radius", item.radiusProperty());
demoUtil.addRadiusControl("Offset", item.offsetProperty());
demoUtil.addColorControl("Background", item.backgroundFillProperty());
demoUtil.addColorControl("BackgroundMouseOn",
	item.backgroundMouseOnFillProperty());
demoUtil.addColorControl("Stroke", item.strokeFillProperty());
demoUtil.addColorControl("StrokeMouseOn",
	item.strokeMouseOnFillProperty());
demoUtil.addBooleanControl("Clockwise", item.clockwiseProperty());
demoUtil.addBooleanControl("BackgroundVisible",
	item.backgroundVisibleProperty());
demoUtil.addBooleanControl("StrokeVisible",
	item.strokeVisibleProperty());
demoUtil.addGraphicControl("Graphic",
	item.graphicProperty());

final Group demoControls = new Group(item, demoUtil);
stage.setScene(new Scene(demoControls));
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
    @Override
    public void handle(final WindowEvent arg0) {
	System.exit(0);
    }
});

stage.setWidth(600);
stage.setHeight(600);
stage.show();
   }
 
源代码29 项目: phoebus   文件: EditorDemo.java
/** JavaFX Start */
@Override
public void start(final Stage stage)
{
    // Call ModelPlugin to trigger its static loading of config file..
    ModelPlugin.logger.fine("Load configuration files");


    editor = new EditorGUI();

    final ObservableList<Node> toolbar = editor.getDisplayEditor().getToolBar().getItems();
    toolbar.add(0, createButton(new LoadModelAction(editor)));
    toolbar.add(1, createButton(new SaveModelAction(editor)));
    toolbar.add(2, new Separator());

    stage.setTitle("Editor");
    stage.setWidth(1200);
    stage.setHeight(600);
    final Scene scene = new Scene(editor.getParentNode(), 1200, 600);
    stage.setScene(scene);
    EditorUtil.setSceneStyle(scene);

    // If ScenicView.jar is added to classpath, open it here
    //ScenicView.show(scene);

    stage.show();



    // .. before the model is loaded which may then use predefined colors etc.
    editor.loadModel(new File(display_file));
    stage.setOnCloseRequest((WindowEvent event) -> editor.dispose());
}
 
源代码30 项目: logbook-kai   文件: BattleDetail.java
/**
 * ウインドウを閉じる時のアクション
 *
 * @param e WindowEvent
 */
@Override
protected void onWindowHidden(WindowEvent e) {
    if (this.timeline != null) {
        this.timeline.stop();
    }
}