I’d like to get some HTML from a page and display it instead of writing my own parsing and trying to display it all with text();
I’ve cobbled this together from examples I’ve found on the old forum and stackoverflow, but it currently just displays a blank window.
Is this possible?
import javax.swing.*;
import java.net.*;
import processing.awt.PSurfaceAWT;
import javax.swing.JFrame;
String site = "https://processing.org/overview/";
void setup() {
JTextPane tp = new JTextPane();
JScrollPane js = new JScrollPane();
js.getViewport().add(tp);
JFrame jf = getJFrame();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.getContentPane().add(js);
jf.pack();
jf.setSize(400, 500);
jf.setVisible(true);
try {
URL url = new URL(site);
tp.setPage(url);
}
catch (Exception e) {
e.printStackTrace();
}
}
JFrame getJFrame() {
PSurfaceAWT surf = (PSurfaceAWT) getSurface();
PSurfaceAWT.SmoothCanvas canvas = (PSurfaceAWT.SmoothCanvas) surf.getNative();
return (JFrame) canvas.getFrame();
}