Webview in Processing

Is there a way to get a sketch to show the content of a webpage and not just the raw html code?
I heard of a way to import javafx webview into the editor, but it requires recompiling the editor!
Any help & advice will be apriciated :3

1 Like

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…

— mnse


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


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);
  Stage stage = new Stage();
  stage.setTitle("JavaFX WebView Example");
  WebView webView = new WebView();
  VBox vBox = new VBox(webView);
  Scene scene = new Scene(vBox, 960, 600);
1 Like

Hello @mnse,

Thank you for this contribution!

I created a separate install of Processing 4.3 with its own preferences.txt file for adding the modules.


There are issues if you do not have the modules in the sketch folder for other sketches:


1 Like

Hi @glv,

Yes, sure! Maybe I missed out to explicitly stated to revert the “run.options” if not required anymore but well, I mistakenly assumed it was understood. :slight_smile:

— mnse

Is it the case that this procedure would have to be repeated for each demo, and that run.options in preferences.txt would have to be reverted to its normal state after each run?

It seems so simple to me to change -addModules in the runtime code to include all the JavaFX modules prior to releasing the editor; I do not understand why it is not done.

Hi @svan,

You could do many things, but you can’t set on runtime as these are VM options to be set, way before you come into play…
But image you are working on a project and finally export it as ie executable, the runtime.options are included by build afterwards roll back.

Or a second approach could be to have a side by side processing installation, one for normal stuff and one for javafx which pointing to a separate preferences.txt (could be modified inside the processing dir, by the default properties file)

— mnse