Search in sources :

Example 36 with JFXPanel

use of javafx.embed.swing.JFXPanel in project drbookings by DrBookings.

the class FXUtils method setupJavaFX.

public static void setupJavaFX() throws RuntimeException {
    final CountDownLatch latch = new CountDownLatch(1);
    SwingUtilities.invokeLater(() -> {
        // initializes JavaFX environment
        new JFXPanel();
        latch.countDown();
    });
    try {
        // wait for SwingUI thread to return (FX environment
        latch.await();
    // ready)
    } catch (final InterruptedException e) {
        throw new RuntimeException(e);
    }
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 37 with JFXPanel

use of javafx.embed.swing.JFXPanel in project jphp by jphp-compiler.

the class UXApplication method runLaterAndWait.

@Signature
public static Memory runLaterAndWait(final Invoker callback) throws Throwable {
    if (isShutdown()) {
        return Memory.NULL;
    }
    if (Platform.isFxApplicationThread()) {
        return callback.call();
    }
    new JFXPanel();
    FutureTask<Memory> futureTask = new FutureTask<>(() -> {
        try {
            return callback.callNoThrow();
        } catch (Exception e) {
            callback.getEnvironment().catchUncaught(e);
            return Memory.NULL;
        }
    });
    Platform.runLater(futureTask);
    try {
        return futureTask.get();
    } catch (InterruptedException | ExecutionException e) {
        throw new CriticalException(e);
    }
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) FutureTask(java.util.concurrent.FutureTask) Memory(php.runtime.Memory) ExecutionException(java.util.concurrent.ExecutionException) CriticalException(php.runtime.exceptions.CriticalException) CriticalException(php.runtime.exceptions.CriticalException) SocketException(java.net.SocketException) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) CustomErrorException(php.runtime.exceptions.CustomErrorException) Signature(php.runtime.annotation.Reflection.Signature)

Example 38 with JFXPanel

use of javafx.embed.swing.JFXPanel in project jphp by jphp-compiler.

the class FXLauncher method readConfig.

@Override
protected void readConfig() {
    super.readConfig();
    Memory fxSplash = getConfigValue("fx.splash");
    if (fxSplash.toBoolean()) {
        InputStream fxSplashStream = getClass().getResourceAsStream(fxSplash.toString());
        if (fxSplashStream == null) {
            System.err.println("Failed to load 'fx.splash': " + fxSplash.toString());
            return;
        }
        new JFXPanel();
        Platform.runLater(() -> {
            Image image = new Image(fxSplashStream);
            ImageViewEx imageView = new ImageViewEx();
            imageView.setAutoSize(true);
            imageView.setImage(image);
            splashStage = new Stage(StageStyle.TRANSPARENT);
            VBox root = new VBox(imageView);
            root.setBackground(null);
            Scene scene = new Scene(root);
            scene.setFill(null);
            splashStage.setScene(scene);
            Memory opacity = getConfigValue("fx.splash.opacity");
            if (opacity.isNotNull()) {
                splashStage.setOpacity(opacity.toDouble());
            }
            Memory alwaysOnTop = getConfigValue("fx.splash.alwaysOnTop");
            if (alwaysOnTop.isNotNull()) {
                splashStage.setAlwaysOnTop(alwaysOnTop.toBoolean());
            }
            splashStage.centerOnScreen();
            splashStage.show();
            splashStage.centerOnScreen();
        });
    }
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) ImageViewEx(org.develnext.jphp.ext.javafx.support.ImageViewEx) Memory(php.runtime.Memory) StringMemory(php.runtime.memory.StringMemory) InputStream(java.io.InputStream) Stage(javafx.stage.Stage) UXImage(org.develnext.jphp.ext.javafx.classes.UXImage) Image(javafx.scene.image.Image) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Example 39 with JFXPanel

use of javafx.embed.swing.JFXPanel in project selenium_java by sergueik.

the class LoginFrame method initMainPanel.

@Override
protected JComponent initMainPanel() {
    JFXPanel panel = new JFXPanel();
    Platform.runLater(() -> {
        webView = new WebView();
        WebEngine engine = webView.getEngine();
        engine.setJavaScriptEnabled(true);
        engine.setUserAgent(USER_AGENT);
        addChangeListener(LoginFrame.this);
        panel.setScene(new Scene(webView));
    });
    return panel;
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) WebEngine(javafx.scene.web.WebEngine)

Example 40 with JFXPanel

use of javafx.embed.swing.JFXPanel in project bmoth by hhu-stups.

the class AppTest method testApp.

@Test
public void testApp() throws InterruptedException {
    // Initializes the JavaFx Platform
    new JFXPanel();
    Future<Void> f = WaitForAsyncUtils.asyncFx(() -> {
        try {
            stage = new Stage();
            new App().start(stage);
        } catch (IOException e) {
            logger.log(Level.SEVERE, "exception during test", e);
        }
    });
    WaitForAsyncUtils.waitFor(f);
    assertEquals(true, stage.isShowing());
    Platform.runLater(() -> stage.close());
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) Stage(javafx.stage.Stage) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

JFXPanel (javafx.embed.swing.JFXPanel)50 Scene (javafx.scene.Scene)16 Test (org.junit.Test)16 CountDownLatch (java.util.concurrent.CountDownLatch)11 Dimension (java.awt.Dimension)6 BorderPane (javafx.scene.layout.BorderPane)6 Stage (javafx.stage.Stage)6 FXMLLoader (javafx.fxml.FXMLLoader)5 WebView (javafx.scene.web.WebView)5 BaseDocumentTest (com.kasirgalabs.etumulator.document.BaseDocumentTest)4 BorderLayout (java.awt.BorderLayout)4 WindowAdapter (java.awt.event.WindowAdapter)4 WindowEvent (java.awt.event.WindowEvent)4 ExecutorService (java.util.concurrent.ExecutorService)4 JFrame (javax.swing.JFrame)4 WebEngine (javafx.scene.web.WebEngine)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 Random (java.util.Random)2 FutureTask (java.util.concurrent.FutureTask)2 Memory (php.runtime.Memory)2