use of javafx.embed.swing.JFXPanel in project open-ecard by ecsec.
the class HTMLPanel method createPanel.
/**
* Create a new JPanel containing the Java FX components to render HTML.
*
* @param mimeType The MimeType of the {@code content} to display.
* @param content The content to display.
* @return A JPanel displaying the content.
*/
public static JPanel createPanel(final String mimeType, final byte[] content) {
contentPane = new JPanel();
jfxPane = new JFXPanel();
contentPane.add(jfxPane);
Platform.runLater(new Runnable() {
@Override
public void run() {
initFx(mimeType, content);
}
});
return contentPane;
}
use of javafx.embed.swing.JFXPanel in project intellij-community by JetBrains.
the class IpnbJfxUtils method createHtmlPanel.
public static JComponent createHtmlPanel(@NotNull final String source, int width) {
final JFXPanel javafxPanel = new JFXPanel() {
@Override
protected void processMouseWheelEvent(MouseWheelEvent e) {
final Container parent = getParent();
final MouseEvent parentEvent = SwingUtilities.convertMouseEvent(this, e, parent);
parent.dispatchEvent(parentEvent);
}
};
javafxPanel.setBackground(IpnbEditorUtil.getBackground());
Platform.runLater(() -> {
final WebView webView = new WebView();
webView.setContextMenuEnabled(false);
webView.setOnDragDetected(event -> {
});
final WebEngine engine = webView.getEngine();
initHyperlinkListener(engine);
final boolean hasMath = source.contains("$");
if (hasMath) {
engine.setOnStatusChanged(event -> adjustHeight(webView, javafxPanel, source));
} else {
engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == Worker.State.SUCCEEDED) {
adjustHeight(webView, javafxPanel, source);
}
});
}
final BorderPane pane = new BorderPane(webView);
final String prefix;
if (hasMath) {
prefix = String.format(ourMathJaxPrefix, width - 500, EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize());
} else {
prefix = String.format(ourPrefix, width - 500);
}
final String content = prefix + convertToHtml(source) + ourPostfix;
engine.loadContent(content);
final Scene scene = new Scene(pane, 0, 0);
javafxPanel.setScene(scene);
updateLaf(LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo, engine, javafxPanel);
});
return javafxPanel;
}
use of javafx.embed.swing.JFXPanel in project ETUmulator by kasirgalabs.
the class BaseConsoleTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException, ExecutionException, TimeoutException {
assert !Platform.isFxApplicationThread();
new JFXPanel();
FutureTask<Void> futureTask = new FutureTask<>(() -> {
console = new BaseConsole(this);
ClassLoader classLoader = BaseConsoleTest.class.getClassLoader();
FXMLLoader fxmlLoader = new FXMLLoader(classLoader.getResource("fxml/Console.fxml"));
fxmlLoader.setControllerFactory((Class<?> param) -> {
return console;
});
fxmlLoader.load();
console = fxmlLoader.getController();
return null;
});
Platform.runLater(futureTask);
futureTask.get(10, TimeUnit.SECONDS);
}
use of javafx.embed.swing.JFXPanel in project ETUmulator by kasirgalabs.
the class RegistersTabTest method testUpdate.
/**
* Test of update method, of class RegistersTab.
*
* @throws java.lang.InterruptedException
* @throws java.util.concurrent.ExecutionException
* @throws java.util.concurrent.TimeoutException
*/
@Test
public void testUpdate() throws InterruptedException, ExecutionException, TimeoutException {
assert !Platform.isFxApplicationThread();
new JFXPanel();
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Void> future = executor.submit(() -> {
registerFile.setValue("r0", 5);
return null;
});
future.get(5, TimeUnit.SECONDS);
executor = Executors.newSingleThreadExecutor();
future = executor.submit(() -> {
pc.setValue(5);
return null;
});
future.get(5, TimeUnit.SECONDS);
executor = Executors.newSingleThreadExecutor();
future = executor.submit(() -> {
lr.setValue(5);
return null;
});
future.get(5, TimeUnit.SECONDS);
executor = Executors.newSingleThreadExecutor();
future = executor.submit(() -> {
registerFile.reset();
pc.reset();
lr.reset();
return null;
});
future.get(5, TimeUnit.SECONDS);
}
use of javafx.embed.swing.JFXPanel in project ETUmulator by kasirgalabs.
the class GUISafeDispatcherTest method testNotifyObservers_Object.
/**
* Test of notifyObservers method, of class GUISafeDispatcher.
*
* @throws java.lang.InterruptedException
*/
@Test
public void testNotifyObservers_Object() throws InterruptedException {
assert !Platform.isFxApplicationThread();
new JFXPanel();
dispatcher.addObserver(this);
expResult = "test0";
latch = new CountDownLatch(1);
dispatcher.notifyObservers(null, expResult);
latch.await(5, TimeUnit.SECONDS);
latch = new CountDownLatch(1);
expResult = "test1";
dispatcher.notifyObservers(null, expResult);
latch.await(5, TimeUnit.SECONDS);
latch = new CountDownLatch(1);
expResult = "test2";
dispatcher.notifyObservers(null, expResult);
latch.await(5, TimeUnit.SECONDS);
}
Aggregations