Search in sources :

Example 11 with WebView

use of javafx.scene.web.WebView in project L42 by ElvisResearchGroup.

the class Frame method initWeb.

private Void initWeb(CountDownLatch latch, JFXPanel jfxPanel, String html) {
    Group root = new Group();
    Scene scene = new Scene(root);
    WebView browser = new WebView();
    this.webEngine = browser.getEngine();
    this.webEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> {
        if (newState == Worker.State.SUCCEEDED) {
            latch.countDown();
        }
    });
    this.webEngine.loadContent(html);
    this.webEngine.setOnAlert(event -> {
        Alert alert = new Alert(AlertType.INFORMATION);
        alert.setTitle("Information Dialog");
        alert.setHeaderText(null);
        alert.setContentText(event.getData());
        alert.showAndWait();
    });
    root.getChildren().add(browser);
    jfxPanel.setScene(scene);
    return null;
}
Also used : Group(javafx.scene.Group) Alert(javafx.scene.control.Alert) Scene(javafx.scene.Scene) WebView(javafx.scene.web.WebView)

Example 12 with WebView

use of javafx.scene.web.WebView in project jabref by JabRef.

the class MathSciNetPaneView method getPane.

StackPane getPane() {
    StackPane root = new StackPane();
    ProgressIndicator progress = new ProgressIndicator();
    progress.setMaxSize(100, 100);
    WebView browser = new WebView();
    // Quick hack to disable navigating
    browser.addEventFilter(javafx.scene.input.MouseEvent.ANY, javafx.scene.input.MouseEvent::consume);
    browser.setContextMenuEnabled(false);
    root.getChildren().addAll(browser, progress);
    mathSciNetId.getExternalURI().ifPresent(url -> browser.getEngine().load(url.toASCIIString()));
    // Hide progress indicator if finished (over 70% loaded)
    browser.getEngine().getLoadWorker().progressProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue.doubleValue() >= 0.7) {
            progress.setVisible(false);
        }
    });
    return root;
}
Also used : ProgressIndicator(javafx.scene.control.ProgressIndicator) WebView(javafx.scene.web.WebView) StackPane(javafx.scene.layout.StackPane)

Example 13 with WebView

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);
}
Also used : Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) VBox(javafx.scene.layout.VBox) URL(java.net.URL)

Example 14 with WebView

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);
}
Also used : DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 15 with WebView

use of javafx.scene.web.WebView in project Gargoyle by callakrsos.

the class SimpleTextView method miOpenNamoWebViewOnAction.

/**
	 * Mime 데이터타입을 Html컨텐츠형태로 조회하기 위한 웹 뷰를 오픈함.
	 * @작성자 : KYJ
	 * @작성일 : 2016. 12. 29.
	 */
@FXML
public void miOpenNamoWebViewOnAction() {
    String content = codeArea.getText();
    try {
        WebView webView = new WebView();
        //			new ContentMimeHtmlAdapter(content)
        //			String encodeToString = Base64.getEncoder().encodeToString(content.getBytes());
        //
        //			byte[] decode = Base64.getDecoder().decode(encodeToString);
        //			String string = new String(decode);
        //			MimeBodyPart part = new MimeBodyPart(new ByteArrayInputStream(content.getBytes()));
        //			Enumeration allHeaders = part.getAllHeaders();
        //			while(allHeaders.hasMoreElements())
        //			{
        //				javax.mail.Header nextElement = (Header) allHeaders.nextElement();
        //
        //				System.out.println(nextElement.getName());
        //				System.out.println(nextElement.getValue());
        //			}
        //
        //			DataHandler dataHandler = part.getDataHandler();
        //			Object transferData = dataHandler.getTransferData(new DataFlavor("text/html"));
        //			System.out.println(transferData);
        //			ContentMimeHtmlAdapter adapter = new ContentMimeHtmlAdapter(content);
        //			File tempFile = adapter.toTempFile();
        //			byte[] decode = Base64.getMimeDecoder().decode(content.getBytes("UTF-8"));
        //			String string = new String(decode);
        FxUtil.createStageAndShow(webView, stage -> {
            stage.setAlwaysOnTop(true);
            stage.initOwner(getScene().getWindow());
            stage.focusedProperty().addListener((oba, o, n) -> {
                if (!n)
                    stage.close();
            });
        });
        javafx.application.Platform.runLater(() -> {
            try {
                MimeToHtmlAdapter adapter = new MimeToHtmlAdapter(content);
                webView.getEngine().loadContent(adapter.getContent());
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MimeToHtmlAdapter(com.kyj.fx.voeditor.visual.framework.word.MimeToHtmlAdapter) WebView(javafx.scene.web.WebView) FXML(javafx.fxml.FXML)

Aggregations

WebView (javafx.scene.web.WebView)19 Scene (javafx.scene.Scene)13 WebEngine (javafx.scene.web.WebEngine)8 ObservableValue (javafx.beans.value.ObservableValue)4 BorderPane (javafx.scene.layout.BorderPane)4 StackPane (javafx.scene.layout.StackPane)4 DarculaLookAndFeelInfo (com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo)3 State (javafx.concurrent.Worker.State)3 JFXPanel (javafx.embed.swing.JFXPanel)3 Button (javafx.scene.control.Button)3 VBox (javafx.scene.layout.VBox)3 URL (java.net.URL)2 ChangeListener (javafx.beans.value.ChangeListener)2 FXML (javafx.fxml.FXML)2 Group (javafx.scene.Group)2 Label (javafx.scene.control.Label)2 ScrollPane (javafx.scene.control.ScrollPane)2 PopupFeatures (javafx.scene.web.PopupFeatures)2 WebEvent (javafx.scene.web.WebEvent)2 JSObject (netscape.javascript.JSObject)2