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);
}
}
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);
}
}
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();
});
}
}
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;
}
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());
}
Aggregations