Can you type text on the displayed screen and make processing use the date to change a variable

Hi

Is it possible to to make a input box on the screen that run the sketch where I can type text or numbers that will influence a variable from the initial run. So the new input is read by processing. One variable is influenced by what I type. And either the screen is updated by the new variable size. Eg. a drawn circle is now larger or smaller. Because a String variable is updated. It alters a int variable through an array and after the value changes. the conditions for the draw is changed. Its also ok if I can type text on the display screen and hit run button and variables have been changed.

Thanks in advance for any suggestions!

1 Like

Is this what you need?

import javax.swing.*;
String text;
text= JOptionPane.showInputDialog("Please input your text.");
println(text);

Note: while this window is up the sketch is paused.
If you want to have the sketch run while this window is active you’ll need to multithread and provide a way to resolve not having the input entered yet.

If you want to further configure the window it may be worth looking into the documentation:

JOptionPane (Java Platform SE 7 ) (oracle.com)

Thank you NumericPrime! That will do the job :smile:

2 Likes