Java Code Examples for javafx.application.Platform#setImplicitExit()

The following examples show how to use javafx.application.Platform#setImplicitExit() . 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: SwingTopComponent.java    From constellation with Apache License 2.0 7 votes vote down vote up
@Override
protected final void initContent() {
    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(500, 500));
    Platform.setImplicitExit(false);
    SwingUtilities.invokeLater(() -> {
        this.content = createContent();

        scrollPane = new JScrollPane(content);
        scrollPane.setHorizontalScrollBarPolicy(getHorizontalScrollPolicy());
        scrollPane.setVerticalScrollBarPolicy(getVerticalScrollPolicy());

        updateFont();

        add(scrollPane, BorderLayout.CENTER);
    });
}
 
Example 2
Source File: DownApplication.java    From proxyee-down with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
  INSTANCE = this;
  stage = primaryStage;
  Platform.setImplicitExit(false);
  //load config
  initConfig();
  //load pdown-rest
  initRest();
  initMacMITMTool();
  initEmbedHttpServer();
  initExtension();
  initTray();
  //xp不支持webview
  if (!OsUtil.isWindowsXP()) {
    initWindow();
    initBrowser();
  }
  loadUri(null, true, true);
}
 
Example 3
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 4
Source File: WebBrowserImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createBrowser() {
    Platform.setImplicitExit(false);
    if( null == browser ) {
        WebView view = new WebView();
        initBrowser( view );
        issue217410Hack(view);

        browser = view;
        INIT_LOCK.release();
    }

    if( null != container ) {
        BorderPane pane = new BorderPane();
        pane.setCenter( browser );
        Scene scene = new Scene( pane );
        scene.setFill( getSceneFillColor() );
        container.setScene( scene );
    }

    if( null != urlToLoad ) {
        _setURL( urlToLoad );
        urlToLoad = null;
    }
}
 
Example 5
Source File: POELevelFx.java    From Path-of-Leveling with MIT License 6 votes vote down vote up
public void setUpFonts() throws Exception{
    Platform.setImplicitExit( false );
    addTrayIcon();
    Font.loadFont(POELevelFx.class.getResource("/fonts/Fontin-Regular.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/Fontin-Italic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/Fontin-Bold.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/Fontin-SmallCaps.ttf").toExternalForm(), 10);

    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Thin.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-ThinItalic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Regular.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-ThinItalic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-MediumItalic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Medium.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Light.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-LightItalic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Italic.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-Bold.ttf").toExternalForm(), 10);
    Font.loadFont(POELevelFx.class.getResource("/fonts/AlegreyaSansSC-BoldItalic.ttf").toExternalForm(), 10);
}
 
Example 6
Source File: Startup.java    From oim-fx with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	javafx.scene.image.Image image = ImageBox.getImagePath("Resources/Images/Logo/logo_64.png");
	primaryStage.getIcons().clear();
	primaryStage.getIcons().add(image);
	Platform.setImplicitExit(false);
}
 
Example 7
Source File: JavaFxHtmlToolkit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Object initHtmlComponent(JComponent c, Consumer<String> titleDisplayer) {
    JFXPanel p = (JFXPanel) c;
    Platform.setImplicitExit(false);
    WebView webView = new WebView();
    BorderPane bp = new BorderPane();
    Scene scene = new Scene(bp, Color.ALICEBLUE);

    class X implements ChangeListener<String>, Runnable {

        private String title;

        public X() {
            super();
        }

        @Override
        public void changed(ObservableValue<? extends String> ov, String t, String t1) {
            title = webView.getEngine().getTitle();
            EventQueue.invokeLater(this);
        }

        @Override
        public void run() {
            if (title != null) {
                titleDisplayer.accept(title);
            }
        }
    }
    final X x = new X();
    webView.getEngine().titleProperty().addListener(x);
    HtmlToolkit.getDefault().execute(x);
    bp.setCenter(webView);
    p.setScene(scene);
    return webView;
}
 
Example 8
Source File: MatchSelectionExample.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
	final List<String> filenames = Files.list(Paths.get(System.getProperty("user.home"))).map(Path::toAbsolutePath).map(Path::toString).collect(Collectors.toList());
	Collections.sort(filenames);
	PlatformImpl.startup(() -> {});
	Platform.setImplicitExit(true);
	Platform.runLater(() -> {

		final MenuButton button = new MenuButton("Select!");
		final DirectoryChooser chooser = new DirectoryChooser();
		final MenuItem chooserButton = new MenuItem("Browse");
		chooserButton.setOnAction(e -> chooser.showDialog(null));

		button.getItems().setAll(
				chooserButton,
				MatchSelectionExample.menu("Recent...", System.out::println, filenames),
				MatchSelectionExample.menu("Favorites...", System.out::println, filenames));


		final Stage stage = new Stage();
		final Scene scene = new Scene(button);
		stage.setScene(scene);
		stage.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
			if (KeyCode.ESCAPE.equals(e.getCode())) {
				if (!e.isConsumed())
					stage.close();
				e.consume();
			}
		});
		stage.show();
	});
}
 
Example 9
Source File: AppStartup.java    From oim-fx with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	javafx.scene.image.Image image = ImageBox.getImagePath("Resources/Images/Logo/logo_64.png");
	primaryStage.getIcons().clear();
	primaryStage.getIcons().add(image);
	Platform.setImplicitExit(false);
}
 
Example 10
Source File: Main.java    From blobsaver with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws IOException {
    Main.primaryStage = primaryStage;
    Parent root = FXMLLoader.load(getClass().getResource("blobsaver.fxml"));
    primaryStage.setTitle("blobsaver " + Main.appVersion);
    primaryStage.setScene(new Scene(root));
    primaryStage.getScene().getStylesheets().add(getClass().getResource("app.css").toExternalForm());
    if (!PlatformUtil.isMac()) {
        primaryStage.getIcons().clear();
        primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("blob_emoji.png")));
    }
    primaryStage.setResizable(false);
    Controller.afterStageShowing();
    Platform.setImplicitExit(false);
    showStage();
    if (appPrefs.getBoolean("Start background immediately", false)) {
        /* I have to show the stage then hide it again in Platform.runLater() otherwise
         * the needed initialization code won't run at the right time when starting the background
         * (for example, the macOS menu bar won't work properly if I don't do this)
         */
        Platform.runLater(() -> {
            hideStage();
            Background.startBackground(false);
        });
    }
    //if in background, hide; else quit
    primaryStage.setOnCloseRequest(event -> {
        event.consume();
        if (Background.inBackground) {
            hideStage();
        } else {
            Platform.exit();
        }
    });
    appPrefs.put("App version", appVersion);
}
 
Example 11
Source File: Maus.java    From Maus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws IOException, ClassNotFoundException {
    Maus.primaryStage = primaryStage;
    /* Ensure that the necessary files exist */
    new PseudoBase().createMausData();
    /* Load data from files - including client data, server settings, etc. */
    new PseudoBase().loadData();
    /* Set up primary view */
    getPrimaryStage().setTitle(MausSettings.CURRENT_VERSION);

    SwingUtilities.invokeLater(this::addAppToTray);
    Platform.setImplicitExit(false);
    Scene mainScene = new Scene(new MainView().getMainView(), 900, 500);
    mainScene.getStylesheets().add(getClass().getResource("/css/global.css").toExternalForm());
    getPrimaryStage().setScene(mainScene);
    getPrimaryStage().getIcons().add(new Image(getClass().getResourceAsStream("/Images/Icons/icon.png")));
    getPrimaryStage().setOnCloseRequest(event -> System.exit(0));

    /* Maus is running! */
    Logger.log(Level.INFO, "Maus is running.");
    getPrimaryStage().initStyle(StageStyle.UNDECORATED);

    /* Set user's IP as Server IP */
    URL whatismyip = new URL("http://checkip.amazonaws.com");
    BufferedReader in = new BufferedReader(new InputStreamReader(
            whatismyip.openStream()));

    String ip = in.readLine();
    MausSettings.CONNECTION_IP = ip;
    getPrimaryStage().show();

    /* Start the server to listen for client connections. */
    Runnable startServer = server;
    new Thread(startServer).start();
}
 
Example 12
Source File: ScrLogoDetails.java    From PolyGlot with MIT License 5 votes vote down vote up
private void setupFilterMenu() {
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.gridheight = GridBagConstraints.RELATIVE;
    c.gridwidth = GridBagConstraints.RELATIVE;

    jPanel1.setLayout(new GridLayout());
    jPanel1.add(fxPanel, c);
    jPanel1.setBackground(Color.white);
    fxPanel.setBackground(Color.white);
    
    final CountDownLatch latch = new CountDownLatch(1);
    Platform.setImplicitExit(false);
    Platform.runLater(() -> {
        fxPanel.setScene(createScene());
        latch.countDown();
    });

    try {
        latch.await();
    } catch (InterruptedException e) {
        IOHandler.writeErrorLog(e);
        InfoBox.error("Form Load Error", "Unable to load Lexicon: " + e.getLocalizedMessage(), core.getRootWindow());
    }
    
    gridTitlePane.setTooltip(new Tooltip(FILTER_LABEL));
}
 
Example 13
Source File: WebViewer.java    From constellation with Apache License 2.0 5 votes vote down vote up
private void init(final String url) {
    Platform.setImplicitExit(false);
    Platform.runLater(() -> {
        Scene scene1 = new Scene(root);
        setScene(scene1);
        WebView webView = new WebView();
        webView.setMaxWidth(Double.MAX_VALUE);
        webView.setMaxHeight(Double.MAX_VALUE);
        //                System.out.println("WEB VIEWER: " + System.identityHashCode(webView.getClass()));
        root.setCenter(webView);
        webView.setContextMenuEnabled(false);
        final WebEngine webEngine = webView.getEngine();
        webEngine.load(url);
        webEngine.locationProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(final ObservableValue<? extends String> observable, final String oldValue, final String newValue) {
                webEngine.load(newValue);
            }
        });
        EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
            @Override
            public void handle(final ActionEvent event) {
                webEngine.load(url.startsWith("http://")
                        ? url
                        : "http://" + url);
            }
        };
    });
}
 
Example 14
Source File: ScrLexicon.java    From PolyGlot with MIT License 5 votes vote down vote up
/**
 * Sets default values to all user editable fields
 */
private void setDefaultValues() {
    chkProcOverride.setSelected(false);
    chkRuleOverride.setSelected(false);
    cmbType.setSelectedIndex(0);
    Platform.setImplicitExit(false);
    Platform.runLater(() -> {
        txtConSrc.setText("");
        txtDefSrc.setText("");
        txtLocalSrc.setText("");
        txtProcSrc.setText("");
        cmbTypeSrc.getSelectionModel().select(0);
    });
}
 
Example 15
Source File: VideoMp4.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
public VideoMp4(String mediaUrlString) {
    Platform.setImplicitExit(false);
    this.mediaUrlString = mediaUrlString;
    initialize();
}
 
Example 16
Source File: TextHTML.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
/** Creates a new instance of TextHTML */
public TextHTML(String locator) {
    Platform.setImplicitExit(false);
    this.wandora = Wandora.getWandora();
    this.locator = locator;
}
 
Example 17
Source File: ObjLoader.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
		PlatformImpl.startup(() -> {});
		// https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html
//		final String objFile = "al.obj";
//		final String objFile = "diamond.obj";
		final String objFile = "alfa147.obj";
		final Path path = Paths.get(System.getProperty("user.home"), "Downloads", objFile);
		final TriangleMesh mesh = new ObjLoader().loadMesh(path);
		final double[] min = {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY};
		final double[] max = {Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY};
		for (int i = 0; i < mesh.getPoints().size(); i += 3) {
			for (int d = 0; d < 3; ++d) {
				min[d] = Math.min(min[d], mesh.getPoints().get(i + d));
				max[d] = Math.max(max[d], mesh.getPoints().get(i + d));
			}
		}
		final Interval interval = Intervals.smallestContainingInterval(new FinalRealInterval(min, max));
		final MeshView mv = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial(Color.WHITE));
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		final Viewer3DFX viewer = new Viewer3DFX(800, 600);
		viewer.meshesEnabledProperty().set(true);
		mv.setOpacity(1.0);
		viewer.setInitialTransformToInterval(interval);
		final MeshView mv2 = new MeshView(mesh);
		mv.setMaterial(Meshes.painteraPhongMaterial());
		mv.setDrawMode(DrawMode.FILL);
		mv.setCullFace(CullFace.BACK);
		mv2.setTranslateX(100);
		viewer.meshesGroup().getChildren().addAll(mv, mv2);
//		final double factor = 1;
//		final double w = 1*factor, h = 2*factor, d = 3*factor;
//		final Box box = new Box(w, h, d);
//		box.setCullFace(CullFace.NONE);
//		box.setOpacity(1.0);
//		box.setMaterial(Meshes.painteraPhongMaterial(Color.RED));
//		viewer.meshesGroup().getChildren().add(box);
		Platform.setImplicitExit(true);
		Platform.runLater(() -> {
			final Scene scene = new Scene(viewer);
			final Stage stage = new Stage();
			stage.setScene(scene);
			stage.setWidth(800);
			stage.setHeight(600);
			stage.show();
		});
	}
 
Example 18
Source File: ExtensionFormLauncher.java    From G-Earth with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    ExtensionInfo extInfo = extension.getAnnotation(ExtensionInfo.class);

    ExtensionForm creator = extension.newInstance();
    ExtensionForm extensionForm = creator.launchForm(primaryStage);

    extensionForm.extension = new Extension(args) {
        @Override
        protected void initExtension() {
            extensionForm.initExtension();
        }

        @Override
        protected void onClick() {
            extensionForm.onClick();
        }

        @Override
        protected void onStartConnection() {
            extensionForm.onStartConnection();
        }

        @Override
        protected void onEndConnection() {
            extensionForm.onEndConnection();
        }

        @Override
        ExtensionInfo getInfoAnnotations() {
            return extInfo;
        }

        @Override
        protected boolean canLeave() {
            return extensionForm.canLeave();
        }

        @Override
        protected boolean canDelete() {
            return extensionForm.canDelete();
        }
    };
    extensionForm.primaryStage = primaryStage;
    Thread t = new Thread(() -> {
        extensionForm.extension.run();
        //when the extension has ended, close this process
        System.exit(0);
    });
    t.start();

    Platform.setImplicitExit(false);

    primaryStage.setOnCloseRequest(event -> {
        event.consume();
        Platform.runLater(() -> {
            primaryStage.hide();
            extensionForm.onHide();
        });
    });
}
 
Example 19
Source File: JavaFxTopComponent.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected final void initContent() {
    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(500, 500));
    Platform.setImplicitExit(false);
    Platform.runLater(() -> {
        this.content = createContent();

        this.scrollPane = new ScrollPane(content);

        this.scene = new Scene(scrollPane);
        scene.getStylesheets().add(JavafxStyleManager.getMainStyleSheet());
        if (createStyle() != null) {
            scene.getStylesheets().add(getClass().getResource(createStyle()).toExternalForm());
        }

        scrollPane.setHbarPolicy(getHorizontalScrollPolicy());
        if (getHorizontalScrollPolicy() == ScrollBarPolicy.NEVER) {
            scrollPane.setFitToWidth(true);
        } else {
            scrollPane.viewportBoundsProperty().addListener((observable, oldValue, newValue) -> {
                // TODO: fix a bug where the width of the scroll can grow infinitely
                scrollPane.setFitToWidth(content.prefWidth(-1) <= newValue.getWidth());
            });
        }
        scrollPane.setVbarPolicy(getVerticalScrollPolicy());
        if (getVerticalScrollPolicy() == ScrollBarPolicy.NEVER) {
            scrollPane.setFitToHeight(true);
        } else {
            scrollPane.viewportBoundsProperty().addListener((observable, oldValue, newValue) -> {
                scrollPane.setFitToHeight(content.prefHeight(-1) <= newValue.getHeight());
            });
        }

        // set the font on initialise
        updateFont();

        jfxContainer.setScene(scene);
        jfxContainer.setBackground(Color.red);
        SwingUtilities.invokeLater(() -> {
            add(jfxContainer, BorderLayout.CENTER);
            validate();
        });
    });
}
 
Example 20
Source File: UseFx.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    Platform.setImplicitExit(true);
}