Webview in Processing

Hi @nuhuhwy,

I think you are refering on that topic !?

you don’t need to recompile the pde to get this to work … just do the following steps …

Steps to do (This example is only for windows x64, for other OS you need to adjust step 4)

  1. open processing pde in java mode
  2. install JavaFX from the contribution manager (Libraries) if not already done
  3. save your sketch, ie TestJavaFX
  4. open explorer skeckbookfolder/libraries/javafx/library/windows-amd64/modules
    and for simplicity drag and drop all javafx jar’s onto your PDE.
  5. copy the code from below (Code) as your sketch code and save
  6. open menu File->Preferences and click on the very bottom the link which pointed out your preferences.txt file
    (an explorer window will open with the directory listed where your preferences.txt
  7. save and close your PDE
  8. Open the preferences.txt in an editor, ie notepad.exe. and search for the line run.options=
    and replace it with the line from (Preferences) below and save the preferences.txt
  9. reopen the TestJavaFX project your PDE again.
  10. click the run button and see what magically happens … :slight_smile:

I know it might a bit of advance but would do the job as a show-case…

Cheers
— mnse


Preferences

run.options=--add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web

Code

import processing.javafx.*;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;

void setup() {  
  size(1, 1, FX2D);
  surface.setVisible(false);
  Stage stage = new Stage();
  stage.setTitle("JavaFX WebView Example");
  WebView webView = new WebView();
  webView.getEngine().load("http://www.processing.org");
  VBox vBox = new VBox(webView);
  Scene scene = new Scene(vBox, 960, 600);
  stage.setScene(scene);
  stage.show();
}
1 Like