use of javafx.embed.swing.JFXPanel in project dwoss by gg-net.
the class PersonaManagmentControllerTest method testJavaFxFxml.
@Test
public void testJavaFxFxml() throws IOException {
if (GraphicsEnvironment.isHeadless())
return;
// Implizit start of JavaFx.
new JFXPanel();
FXMLLoader loader = new FXMLLoader(PersonaManagmentController.loadFxml());
loader.load();
assertThat((PersonaManagmentController) loader.getController()).isNotNull();
}
use of javafx.embed.swing.JFXPanel in project TrayNotification by PlusHaze.
the class ReadMeTest method initializeJavaFX.
@BeforeClass
public static void initializeJavaFX() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
SwingUtilities.invokeLater(() -> {
// initializes JavaFX environment
new JFXPanel();
latch.countDown();
});
latch.await();
}
use of javafx.embed.swing.JFXPanel in project PokeGOAPI-Java by Grover-c13.
the class SolveCaptchaExample method completeCaptcha.
private static void completeCaptcha(final PokemonGo api, final String challengeURL) {
// Run this on the swing thread
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// Run on JFX Thread
Platform.runLater(new Runnable() {
@Override
public void run() {
JFXPanel panel = new JFXPanel();
// Create a WebView and WebEngine to display the captcha from challengeURL.
WebView view = new WebView();
WebEngine engine = view.getEngine();
// Set UserAgent so the captcha shows correctly in the WebView.
engine.setUserAgent(CaptchaSolveHelper.USER_AGENT);
engine.load(challengeURL);
final JFrame frame = new JFrame("Solve Captcha");
// Register listener to receive the token when the captcha has been solved from inside the WebView.
CaptchaSolveHelper.Listener listener = new CaptchaSolveHelper.Listener() {
@Override
public void onTokenReceived(String token) {
System.out.println("Token received: " + token + "!");
// Remove this listener as we no longer need to listen for tokens, the captcha has been solved.
CaptchaSolveHelper.removeListener(this);
try {
// Close this window, it not valid anymore.
frame.setVisible(false);
frame.dispose();
if (api.verifyChallenge(token)) {
System.out.println("Captcha was correctly solved!");
} else {
// verifyChallenge will receive a new captcha url if this one is invalid
System.out.println("Captcha was incorrectly solved! Please try again.");
}
} catch (Exception e) {
Log.e("Main", "Error while solving captcha!", e);
}
}
};
CaptchaSolveHelper.registerListener(listener);
// Applies the WebView to this panel
panel.setScene(new Scene(view));
frame.getContentPane().add(panel);
frame.setSize(500, 500);
frame.setVisible(true);
// Don't allow this window to be closed
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.out.println("Please solve the captcha before closing the window!");
}
});
}
});
}
});
}
use of javafx.embed.swing.JFXPanel in project BlocklyArduinoIDEPlugin by technologiescollege.
the class LedMatrixPlugin method initGUI.
private void initGUI() {
window = new JFrame();
window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
window.setLayout(new BorderLayout());
window.setSize(1024, 768);
window.setLocationRelativeTo(null);
window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
SwingUtilities.invokeLater(() -> {
Platform.runLater(() -> {
// browser.webEngine.load("about:blank");
SwingUtilities.invokeLater(() -> {
// System.out.println("test");
try {
e.getWindow().dispose();
} catch (NullPointerException ex) {
// System.out.println("This is a bug in java: https://bugs.openjdk.java.net/browse/JDK-8089371");
}
});
});
});
}
});
jfxPanel = new JFXPanel();
jfxPanel.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT));
window.add(jfxPanel, BorderLayout.CENTER);
window.setVisible(true);
Platform.runLater(() -> {
showBrowser();
});
}
use of javafx.embed.swing.JFXPanel in project BlocklyArduinoIDEPlugin by technologiescollege.
the class StartupApplet method init.
@Override
public void init() {
LedMatrixPlugin.startTimestamp = System.currentTimeMillis();
fxContainer = new JFXPanel();
fxContainer.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT));
add(fxContainer, BorderLayout.CENTER);
Platform.setImplicitExit(false);
Runnable activeRunnable = new Runnable() {
@Override
public void run() {
createScene();
}
};
Platform.runLater(activeRunnable);
}
Aggregations