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
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)
- open processing pde in java mode
- install JavaFX from the contribution manager (Libraries) if not already done
- save your sketch, ie TestJavaFX
- open explorer skeckbookfolder/libraries/javafx/library/windows-amd64/modules
and for simplicity drag and drop all javafx jar’s onto your PDE. - copy the code from below (Code) as your sketch code and save
- 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 - save and close your PDE
- 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 - reopen the TestJavaFX project your PDE again.
- click the run button and see what magically happens …
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();
}
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.
Reference:
There are issues if you do not have the modules in the sketch folder for other sketches:
:)
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.
Cheers
— 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)
Cheers
— mnse