# Displaying HTML in JFrame

**URL:** <https://discourse.processing.org/t/displaying-html-in-jframe/8307>\
**Category:** Coding Questions\
**Created:** [February 12, 2019, 12:35am UTC](https://discourse.processing.org/t/displaying-html-in-jframe/8307 "2019-02-12T00:35:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmccandless](https://avatars.discourse-cdn.com/v4/letter/l/f0a364/32.png) [@lmccandless](https://discourse.processing.org/u/lmccandless)\
**Post date:** [February 12, 2019, 12:35am UTC](https://discourse.processing.org/t/displaying-html-in-jframe/8307/1 "2019-02-12T00:35:37Z")

</div>

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?

```auto
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();
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [February 12, 2019, 5:55am UTC](https://discourse.processing.org/t/displaying-html-in-jframe/8307/2 "2019-02-12T05:55:39Z")

</div>

> [@lmccandless](#):
>
> Is this possible?

If it’s possible I’ve got no idea how to add components to the Processing’s own canvas. 😑

What I always do is to create my own JFrame, like I did in this sketch link: 🖼

> [@Filling Dinamyc Arrays\[\]\[\]](https://discourse.processing.org/t/filling-dinamyc-arrays/7049/5):
>
> That makes the code lighter. No need for [TableColumn](http://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/table/TableColumn.html#%3Cinit%3E(int)) this time. sweat_smile Just a simple call to JTable::updateUI() instead after appending a new row to the grid container: call_me_hand[Docs.Oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/JTable.html#updateUI()](http://Docs.Oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/JTable.html#updateUI()) Here’s the new version of “JTable Example” that dynamically appends rows instead of columns: wink /\*\* \* JTable Example II (v1.0.2) \* GoToLoop (2019/Jan/01) \* https://Discourse.Processing.org/t/filling-dinamyc-…
