本文整理了Java中javafx.scene.web.WebView
类的一些代码示例,展示了WebView
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView
类的具体详情如下:
包路径:javafx.scene.web.WebView
类名称:WebView
暂无
代码示例来源:origin: stackoverflow.com
public class SampleController implements Initializable {
@FXML // fx:id="webView"
private WebView webView; // Value injected by FXMLLoader
@Override // This method is called by the FXMLLoader when initialization is complete
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
webView.getEngine().loadContent("<iframe width='420' height='315' src='http://www.youtube.com/embed/ZDzVLhjB3bk' />");
}
}
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine
public Browser() {
super();
Platform.runLater(() -> {
browser = new WebView();
webEngine = browser.getEngine();
getChildren().add(browser);
});
}
}
代码示例来源:origin: stackoverflow.com
private void expandToContentHeight() {
try {
WebView webView = getWebview();
String heightText = webView.getEngine().executeScript("document.body.offsetHeight").toString();
double height = Double.valueOf(heightText.replace("px", ""));
Platform.runLater(new Runnable() {
@Override
public void run() {
System.out.println(height);
if (height != 0.0)
webView.setPrefHeight(height);
}
});
}
catch (Exception ex) {
LOG.error(ex);
LOG.debug("Error occurred in method expandToContentHeight");
}
}
代码示例来源:origin: stackoverflow.com
public void requestFocus() {
HTMLEditorSkin skin = (HTMLEditorSkin) editor.getSkin();
try {
Field f = skin.getClass().getDeclaredField("webView");
f.setAccessible(true);
WebView wv = (WebView) f.get(skin);
Platform.runLater(() -> {
wv.requestFocus();
wv.getEngine().executeScript("document.body.focus()");
wv.getEngine().executeScript(
"var el = document.body;\n" +
"if (typeof window.getSelection != \"undefined\"\n" +
" && typeof document.createRange != \"undefined\") {\n" +
" var range = document.createRange();\n" +
" range.selectNodeContents(el);\n" +
" range.collapse(false);\n" +
" var sel = window.getSelection();\n" +
" sel.removeAllRanges();\n" +
" sel.addRange(range);\n" +
" } else if (typeof document.body.createTextRange != \"undefined\") {\n" +
" var textRange = document.body.createTextRange();\n" +
" textRange.moveToElementText(el);\n" +
" textRange.collapse(false);\n" +
" textRange.select();\n" +
" }");
});
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
代码示例来源:origin: org.apidesign.html/boot-fx
private WebView newView(final URL url, final FXPresenter onLoad) {
final WebView view = new WebView();
view.setContextMenuEnabled(false);
view.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> t) {
final Worker<Void> w = view.getEngine().getLoadWorker();
w.stateProperty().addListener(new ChangeListener<Worker.State>() {
@Override
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-demoapp
Runnable initWebView = () -> {
try {
WebView browser = new WebView();
webEngine = browser.getEngine();
layout.getChildren().add(browser);
browser.widthProperty().addListener(e -> mapResized());
browser.heightProperty().addListener(e -> mapResized());
代码示例来源:origin: cpesch/RouteConverter
protected WebView createWebView() {
try {
final WebView webView = new WebView();
double browserScaleFactor = getBrowserScaleFactor();
if (browserScaleFactor != 1.0)
webView.setZoom(browserScaleFactor);
log.info(format("Browser is scaled with factor %f, screen resolution is %d dpi", browserScaleFactor, Toolkit.getDefaultToolkit().getScreenResolution()));
webView.getEngine().setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() {
public WebEngine call(PopupFeatures config) {
webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<State>() {
private int startCount;
method.invoke(webView.getEngine(), USER_AGENT);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
代码示例来源:origin: com.machinepublishers/jbrowserdriver
WebView view = new WebView();
view.setCache(false);
StackPane root = new StackPane();
root.setCache(false);
stage.initStyle(StageStyle.UNDECORATED);
WebEngine engine = view.getEngine();
File style = File.createTempFile("jbd_style_", ".css");
style.deleteOnExit();
代码示例来源:origin: com.github.vatbub/common.view.motd
rssWebView.prefHeightProperty().addListener((observableValue, number, number2) -> stage.setHeight((double) number2 + closeButton.prefHeightProperty().doubleValue() + 85));
rssWebView.getEngine().getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != Worker.State.SUCCEEDED) {
return;
Object result = rssWebView.getEngine().executeScript("document.getElementById('motdContent').offsetHeight");
if (result instanceof Integer) {
Integer i = (Integer) result;
double height = new Double(i);
height = height + 20;
rssWebView.setPrefHeight(height);
rssWebView.getPrefHeight();
rssWebView.getEngine().loadContent(content.toString());
代码示例来源:origin: PhoenicisOrg/phoenicis
@Override
protected void drawStepContent() {
super.drawStepContent();
webView.prefWidthProperty().bind(getContentPane().widthProperty());
webView.getEngine().setUserAgent("use required / intended UA string");
this.addToContentPane(webView);
}
代码示例来源:origin: org.copper-engine/copper-monitoring-client
final int fixSize = history.getItems().size();
sqlEditor.getEngine().loadContent(codeMirrorFormatter.format("", CodeFormatLanguage.SQL, false));
sqlEditor.setOnKeyReleased(new EventHandler<Event>() {
@Override
public void handle(Event event) {
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-templatesui
} catch (ClassNotFoundException ignore) {
v = new WebView();
BorderPane bp = new BorderPane();
Scene scene = new Scene(bp, Color.ALICEBLUE);
代码示例来源:origin: org.beryx.viewreka/viewreka-fxui
/**
* @param chartParentPane that should contain the {@link WebView} used by this chart controller
* @param webEngineConsumer a {@link WebEngine} consumer that knows how to retrieve the content to be displayed, without relying on the value returned by {@link #createChartData()}
*/
public HtmlChartController(Pane chartParentPane, Consumer<WebEngine> webEngineConsumer) {
this.webEngineConsumer = webEngineConsumer;
chartParentPane.getChildren().add(webView);
chartParentPane.widthProperty().addListener((obs, oldVal, newVal) -> {webView.setPrefWidth(newVal.doubleValue());});
chartParentPane.heightProperty().addListener((obs, oldVal, newVal) -> {webView.setPrefHeight(newVal.doubleValue());});
}
代码示例来源:origin: stackoverflow.com
void editorWebViewRequestFocus()
{
final WebView view = (WebView) ((GridPane) ((HTMLEditorSkin) editor.getSkin()).getChildren().get( 0 )).getChildren().get( 2 );
Platform.runLater( () ->
{
view.fireEvent( new MouseEvent( MouseEvent.MOUSE_PRESSED, 100, 100, 200, 200, MouseButton.PRIMARY, 1, false, false, false, false,
false, false, false, false, false, false, null ) );
editor.requestFocus();
view.fireEvent( new MouseEvent( MouseEvent.MOUSE_RELEASED, 100, 100, 200, 200, MouseButton.PRIMARY, 1, false, false, false, false,
false, false, false, false, false, false, null ) );
} );
}
代码示例来源:origin: org.netbeans.html/net.java.html.boot.fx
private WebView newView(final URL url, final AbstractFXPresenter onLoad) {
final WebView view = new WebView();
view.setContextMenuEnabled(false);
Stage newStage;
BorderPane bp;
final Worker<Void> w = view.getEngine().getLoadWorker();
w.stateProperty().addListener(new ChangeListener<Worker.State>() {
private String previous;
代码示例来源:origin: stackoverflow.com
view.fireEvent(new MouseEvent(MouseEvent.MOUSE_PRESSED, 100, 100, 200, 200, MouseButton.PRIMARY, 1, false, false, false, false, false, false, false, false, false, false, null));
editor.requestFocus();
view.fireEvent(new MouseEvent(MouseEvent.MOUSE_RELEASED, 100, 100, 200, 200, MouseButton.PRIMARY, 1, false, false, false, false, false, false, false, false, false, false, null));
});
代码示例来源:origin: stackoverflow.com
public class WorkSpace
{
@FXML private WebView web;
public void setAddress( String address )
{
web.getEngine().load( address );
}
}
代码示例来源:origin: no.tornado/tornadofx-controls
public InlineHTML() {
getStyleClass().add("inline-html");
view = new WebView();
getChildren().add(view);
content.addListener((observable, oldValue, newValue) ->
view.getEngine().loadContent(newValue));
}
代码示例来源:origin: com.machinepublishers/jbrowserdriver
context.item().httpListener.get().resetStatusCode();
context.item().view.get().fireEvent(
new javafx.scene.input.KeyEvent(
javafx.scene.input.KeyEvent.KEY_TYPED, new String(new int[] { codePoint }, 0, 1), "", KeyCode.UNDEFINED,
代码示例来源:origin: stackoverflow.com
@FXML private HTMLEditor editor;
...
public void insertTextToCurrentFeatureCursorPosition(String text) {
WebView webView = (WebView) editor.lookup(".web-view");
WebPage webPage = Accessor.getPageFor(webView.getEngine());
webPage.executeCommand("insertHTML", text);
}
内容来源于网络,如有侵权,请联系作者删除!