use of javafx.scene.web.WebView in project POL-POM-5 by PlayOnLinux.
the class StepRepresentationHtmlPresentation method drawStepContent.
@Override
protected void drawStepContent() {
final String title = this.getParentWizardTitle();
VBox contentPane = new VBox();
contentPane.setId("presentationBackground");
Label titleWidget = new Label(title + "\n\n");
titleWidget.setId("presentationTextTitle");
WebView webView = new WebView();
VBox.setVgrow(webView, Priority.ALWAYS);
webView.getEngine().loadContent(htmlToShow);
final URL style = getClass().getResource(String.format("/org/phoenicis/javafx/themes/%s/description.css", getParent().getThemeManager().getCurrentTheme().getShortName()));
webView.getEngine().setUserStyleSheetLocation(style.toString());
contentPane.getChildren().addAll(webView);
getParent().getRoot().setCenter(contentPane);
}
use of javafx.scene.web.WebView in project open-ecard by ecsec.
the class HTMLPanel method initFx.
/**
* Initializes the Java FX components and fills them with content.
*
* @param mimeType The MimeType of the {@code content} to display.
* @param content The content to display.
*/
private static void initFx(String mimeType, byte[] content) {
BorderPane borderPane = new BorderPane();
browser = new WebView();
WebEngine engine = browser.getEngine();
engine.loadContent(new String(content, Charset.forName("UTF-8")));
borderPane.setCenter(browser);
Scene scene = new Scene(borderPane, 400, 200);
jfxPane.setScene(scene);
}
use of javafx.scene.web.WebView in project tilesfx by HanSolo.
the class MapTileSkin method initGraphics.
// ******************** Initialization ************************************
@Override
protected void initGraphics() {
super.initGraphics();
mouseHandler = event -> {
if (event.getClickCount() == 2) {
centerLocation();
}
};
locationListener = e -> redraw();
poiListener = c -> {
while (c.next()) {
if (c.wasPermutated()) {
// Get items that have been permutated in list
for (int i = c.getFrom(); i < c.getTo(); ++i) {
updatePoi(tile.getPoiList().get(i));
}
} else if (c.wasUpdated()) {
// Get items that have been updated in list
for (int i = c.getFrom(); i < c.getTo(); ++i) {
updatePoi(tile.getPoiList().get(i));
}
} else if (c.wasAdded()) {
c.getAddedSubList().forEach(poi -> addPoi(poi));
} else if (c.wasRemoved()) {
c.getRemoved().forEach(poi -> removePoi(poi));
}
}
};
titleText = new Text();
titleText.setFill(tile.getTitleColor());
Helper.enableNode(titleText, !tile.getTitle().isEmpty());
text = new Text(tile.getText());
text.setFill(tile.getTextColor());
Helper.enableNode(text, tile.isTextVisible());
webView = new WebView();
webView.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
webView.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
webView.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
webEngine = webView.getEngine();
webEngine.getLoadWorker().stateProperty().addListener((ov, o, n) -> {
if (Worker.State.SUCCEEDED == n) {
readyToGo = true;
if (MapProvider.BW != tile.getMapProvider()) {
changeMapProvider(tile.getMapProvider());
}
updateLocation();
updateLocationColor();
tile.getPoiList().forEach(poi -> addPoi(poi));
addTrack(tile.getTrack());
updateTrackColor();
}
});
URL maps = Tile.class.getResource("osm.html");
webEngine.load(maps.toExternalForm());
getPane().getChildren().addAll(titleText, webView, text);
}
use of javafx.scene.web.WebView in project intellij-plugins by StepicOrg.
the class StudyBrowserWindow method initComponents.
private void initComponents() {
Platform.runLater(() -> {
pane = new StackPane();
webComponent = new WebView();
engine = webComponent.getEngine();
pane.getChildren().add(webComponent);
initHyperlinkListener();
initConsoleListener();
Scene scene = new Scene(pane);
panel.setScene(scene);
panel.setVisible(true);
updateLaf(LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo);
});
add(panel, BorderLayout.CENTER);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
}
use of javafx.scene.web.WebView 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!");
}
});
}
});
}
});
}
Aggregations