List of usage examples for javafx.scene.web WebView getEngine
public final WebEngine getEngine()
From source file:de.chaosfisch.uploader.gui.renderer.TagTextArea.java
private void initPicker(final WebView webView) { webView.getEngine().loadContent(getInlineHtml()); webView.setContextMenuEnabled(false); webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() { @Override//from ww w . j a va2 s .c o m public void handle(final WebEvent<String> event) { tags.set(event.getData()); } }); getChildren().add(webView); }
From source file:net.sf.anathema.framework.presenter.action.about.AnathemaAboutAction.java
@SuppressWarnings("ConstantConditions") private void showCredits(MigPane parent) { try {// w ww . j av a2s. c o m InputStream content = getClass().getClassLoader().getResourceAsStream("about.md"); URL stylesheet = getClass().getClassLoader().getResource("aboutPage.css"); String markdownContent = IOUtils.toString(content); HtmlText htmlText = new HtmlConverter().convert(new WikiText(markdownContent)); final WebView webView = new WebView(); webView.getEngine().setUserStyleSheetLocation(stylesheet.toExternalForm()); webView.getEngine().loadContent(htmlText.getHtmlText()); parent.add(webView, new CC().pad(0, 2, 0, 2)); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:Main.java
private void createClipList(GridPane grid) { final VBox vbox = new VBox(30); vbox.setAlignment(Pos.TOP_CENTER);//www. j a v a2 s .co m final Label clipLabel = new Label("Code Monkey To-Do List:"); clipLabel.setId("clipLabel"); final Button getUpButton = new Button("Get Up, Get Coffee"); getUpButton.setPrefWidth(300); getUpButton.setOnAction(createPlayHandler(coffeeClip)); final Button goToJobButton = new Button("Go to Job"); goToJobButton.setPrefWidth(300); goToJobButton.setOnAction(createPlayHandler(jobClip)); final Button meetingButton = new Button("Have Boring Meeting"); meetingButton.setPrefWidth(300); meetingButton.setOnAction(createPlayHandler(meetingClip)); final Hyperlink link = new Hyperlink("About Code Monkey..."); link.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { WebView wv = new WebView(); wv.getEngine().load("http://www.jonathancoulton.com/2006/04/14/" + "thing-a-week-29-code-monkey/"); Scene scene = new Scene(wv, 720, 480); Stage stage = new Stage(); stage.setTitle("Code Monkey"); stage.setScene(scene); stage.show(); } }); vbox.getChildren().addAll(clipLabel, getUpButton, goToJobButton, meetingButton, link); GridPane.setHalignment(vbox, HPos.CENTER); GridPane.setHgrow(vbox, Priority.ALWAYS); GridPane.setVgrow(vbox, Priority.ALWAYS); grid.add(vbox, 0, 0, GridPane.REMAINING, 1); }
From source file:org.springsource.ide.eclipse.commons.browser.javafx.JavaFxBrowserManager.java
public void setClient(WebView view) { this.view = view; this.engine = view.getEngine(); JSObject window = (JSObject) engine.executeScript("window"); window.setMember("ide", this); onLoadFunctions = new ArrayList<IEclipseToBrowserFunction>(); currentUrl = view.getEngine().locationProperty().get(); //Need to remove any query parameters that might break pattern matching for extensions currentUrl = StringUtils.substringBeforeLast(currentUrl, "?"); currentUrl = StringUtils.substringBeforeLast(currentUrl, "&"); loadInitialFunctions();//from ww w .ja v a2 s. c o m }
From source file:io.uploader.drive.auth.webbrowser.SimpleBrowserImpl.java
public SimpleBrowserImpl(Stage stage, String url) throws IOException { super();/* w w w . j a v a2s.c om*/ Preconditions.checkNotNull(stage); this.stage = stage; stage.setTitle("Drive Uploader - Authentication"); UiUtils.setStageAppSize(stage); Scene scene = new Scene(new Group()); AnchorPane root = new AnchorPane(); final WebView browser = new WebView(); webEngine = browser.getEngine(); /* Menu settingsMenu = new Menu ("Settings") ; MenuItem proxy = new MenuItem ("Proxy") ; settingsMenu.getItems().add(proxy) ; MenuBar menuBar = new MenuBar () ; menuBar.getMenus().add(settingsMenu) ; proxy.setOnAction(new EventHandler<ActionEvent> () { @Override public void handle(ActionEvent event) { try { ProxySettingDialog dlg = new ProxySettingDialog (stage, Configuration.INSTANCE) ; dlg.showDialog(); } catch (IOException e) { logger.error("Error occurred while opening the proxy setting dialog", e); } }});*/ FXMLLoader mainMenuLoader = new FXMLLoader(getClass().getResource("/fxml/MainMenu.fxml")); VBox mainMenuBar = (VBox) mainMenuLoader.load(); AnchorPane.setTopAnchor(mainMenuBar, 0.0); AnchorPane.setLeftAnchor(mainMenuBar, 0.0); AnchorPane.setRightAnchor(mainMenuBar, 0.0); MainMenuController mainMenuController = mainMenuLoader.<MainMenuController>getController(); mainMenuController.setOwner(stage); mainMenuController.setConfiguration(Configuration.INSTANCE); mainMenuController.hideAccountMenu(true); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(browser); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); if (StringUtils.isNotEmpty(url)) { goTo(url); } if (DriveUploader.isMacOsX()) { AnchorPane.setTopAnchor(scrollPane, 5.0); } else { AnchorPane.setTopAnchor(scrollPane, 35.0); } AnchorPane.setLeftAnchor(scrollPane, 5.0); AnchorPane.setRightAnchor(scrollPane, 5.0); AnchorPane.setBottomAnchor(scrollPane, 5.0); root.getChildren().add(mainMenuBar); root.getChildren().addAll(scrollPane); scene.setRoot(root); stage.setScene(scene); }
From source file:clientechat.TestList.java
@Override public void start(Stage primaryStage) { WebView wv = new WebView(); Button btn = new Button(); TextField textField = new TextField(); VBox vb = new VBox(); WebEngine appendEngine = wv.getEngine(); btn.setOnAction(new EventHandler<ActionEvent>() { @Override//from www .j a va2s . co m public void handle(ActionEvent event) { executejQuery(appendEngine, "$('#content').append(\"<p align=right><b>World!" + escapeHtml(textField.getText()) + "<b><p>\");"); executejQuery(appendEngine, "$(\"html, body\").animate({ scrollTop: $(document).height()-$(window).height() });"); } }); wv.getEngine().loadContent( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + "<head>\n" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" + "<title>Documento sin ttulo</title>\n" + "</head>\n" + "\n" + "<body id=\"content\">\n" + " \n" + "</body>\n" + "</html>"); vb.getChildren().addAll(wv, btn, textField); Scene scene = new Scene(vb); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
From source file:view.TimelinePanel.java
/** * Creates new form TimelinePanel/*from w w w . j a va2s . c om*/ */ public TimelinePanel() { initComponents(); fxPanel = new JFXPanel(); final Dimension size = new Dimension(960, 750); fxPanel.setSize(size); setLayout(new BorderLayout(0, 0)); add(fxPanel); Platform.runLater(new Runnable() { // this will run initFX as JavaFX-Thread @Override public void run() { Group group = new Group(); Scene scene = new Scene(group); fxPanel.setScene(scene); WebView webView = new WebView(); group.getChildren().add(webView); webView.setMinSize(size.getWidth(), size.getHeight()); webView.setMaxSize(size.getWidth(), size.getHeight()); WebEngine webEngine = webView.getEngine(); webEngine.load( "http://cdn.knightlab.com/libs/timeline/latest/embed/index.html?source=0Ag1_iE674IuvdEFaZi0wOVBFY2l2OHdPUWlrZEMwaHc&font=Bevan-PotanoSans&maptype=toner&lang=en"); } }); }
From source file:gisintegration.SimpleSwingBrowser.java
private void createScene() { Platform.runLater(new Runnable() { @Override/* w w w . ja v a2 s . c o m*/ public void run() { WebView view = new WebView(); engine = view.getEngine(); // engine.titleProperty().addListener(new ChangeListener<String>() { // @Override // public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) { // SwingUtilities.invokeLater(new Runnable() { // @Override // public void run() { // SimpleSwingBrowser.this.setTitle(newValue); // } // }); // } // }); engine.setOnStatusChanged(new EventHandler<WebEvent<String>>() { @Override public void handle(final WebEvent<String> event) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { lblStatus.setText(event.getData()); } }); } }); // engine.locationProperty().addListener(new ChangeListener<String>() { // @Override // public void changed(ObservableValue<? extends String> ov, String oldValue, final String newValue) { // SwingUtilities.invokeLater(new Runnable() { // @Override // public void run() { // txtURL.setText(newValue); // } // }); // } // }); engine.getLoadWorker().workDoneProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, final Number newValue) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { progressBar.setValue(newValue.intValue()); } }); } }); engine.getLoadWorker().exceptionProperty().addListener(new ChangeListener<Throwable>() { public void changed(ObservableValue<? extends Throwable> o, Throwable old, final Throwable value) { if (engine.getLoadWorker().getState() == FAILED) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(panel, (value != null) ? engine.getLocation() + "\n" + value.getMessage() : engine.getLocation() + "\nUnexpected error.", "Loading error...", JOptionPane.ERROR_MESSAGE); } }); } } }); jfxPanel.setScene(new Scene(view)); } }); }
From source file:de.bayern.gdi.gui.Controller.java
private void displayHTMLFileAsPopup(String popuptitle, String pathToFile) throws IOException { WebView web = new WebView(); InputStream htmlPage = Misc.getResource(pathToFile); String content = IOUtils.toString(htmlPage, "UTF-8"); web.getEngine().loadContent(content); WebViewWindow wvw = new WebViewWindow(web, popuptitle); wvw.popup();/*www .jav a 2s . c om*/ }