# showMessageDialog() function gives an error

**URL:** https://discourse.processing.org/t/showmessagedialog-function-gives-an-error/34332
**Category:** Beginners
**Created:** [December 28, 2021, 9:26am UTC](https://discourse.processing.org/t/showmessagedialog-function-gives-an-error/34332 "2021-12-28T09:26:13Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [December 28, 2021, 2:30pm UTC](https://discourse.processing.org/t/showmessagedialog-function-gives-an-error/34332/2 "2021-12-28T14:30:36Z")

</div>

Hello,

Here is a working example that replaced _frame_ with _null_:

> [@Open console instead of window](https://discourse.processing.org/t/open-console-instead-of-window/31040/8):
>
> Hello, There is always javax.swing.JOptionPane for simple IO: import javax.swing.JOptionPane; int col; void setup() { } void draw() { background(col); } void keyPressed() { thread("MessageDialog\_thread"); } void MessageDialog\_thread() { String strInp = JOptionPane.showInputDialog(null,"Enter a color 0 to 255:"); col = int(strInp); JOptionPane.showMessageDialog(null, col, "Output", JOptionPane.PLAIN\_MESSAGE); }slight_smile

Adding this to your code will also work:

```auto
    import javax.swing.JFrame;
    JFrame frame = new JFrame("JOptionPane showMessageDialog example");

```

Insight gleaned from here:  
_[Java: JOptionPane showMessageDialog examples (part 1) | alvinalexander.com](https://alvinalexander.com/java/joptionpane-showmessagedialog-examples-1/)_

`:)`

---

_[View the full topic](https://discourse.processing.org/t/showmessagedialog-function-gives-an-error/34332)._
