We are about to switch to a new forum software. Until then we have removed the registration on this forum.
The idea is that the input pane will receive a character or characters, then write it on the canvas in some location. Any ideas on how to execute this?
Answers
Please don't post duplicates. Continue here: https://forum.processing.org/two/discussion/21753/how-to-add-character-from-joptionpane-to-an-array-and-prevent-duplicate-entries#latest
@koogs
Kf
@kfrajer This is not a duplicate post. The previous asks how to add it to an array, not have it show up on the canvas.
https://processing.org/reference/text_.html
Also https://processing.org/reference/textAlign_.html
Kf
pseudocode time, but I have figured it out.
String x;
x= JOptionPane.showInputDialog(null, "enter whatever");
char y= x.charAt(0); // converts input from pane to a character
if (someArray.indexOf(y) >=0)// checks if y is in said array
{ //whatever}
if (getWord.indexOf(y) ==#){//where # is the bin number the character is contained in
text(y,20,20);}// displays the correct letter, the location
Excuse me, is JOptionPane available in processing 3? Does is provide a text are input field? Similar to an editor? Thanks !
Chrisir
@Chrisir -- JOptionPane is part of Java Swing -- it creates a pop-up dialog:
So you include it at the top of a sketch like this:
Lately we have been getting a lot of forum questions and posts about it -- I wonder if there is a class somewhere that is requiring it for user input, or a popular video tutorial that uses it.
https://Forum.Processing.org/two/discussions/tagged/joptionpane
https://Gist.GitHub.com/GoToLoop/bba0c288aaeeb5ef9bb1
https://Gist.GitHub.com/GoToLoop/8017bc38b8c8e0a5b70b
I am still looking for a text area that works under P3D for my 3D turtle
@Chrisir
This is not the best but a textfield on P3D from controlP5. Use the >>`<< symbol to clear the text area. You can type and press backspace. You get the scrollbar when you reach the vertical limit of your text area. However, it does not respond to mouse actions like move cursor or selecting text.
Kf
Thanks a ton!
Great!
I especially need cursor up down left right
Backspace and delete
I don't have time today but I will try
Thank you!
Ok... so for my last post... nahh it is an improvement but not enough.
For key codes... https://forum.processing.org/two/discussion/comment/51840/#Comment_51840
and the real deal... still to be tested in P3D but it looks promising even if it only works in 2D, check calsign's post:
https://forum.processing.org/one/topic/text-box-cursor-rendering-improvment.html
Kf
@kfrajer:
I just tried your controlP5 code with my 3D Turtle
It is not a good textarea though.
(in a P3D sketch!)
I haven't tried the other two links but this controlP5 was very frustrating.
Even my editor is much better than this.
Chrisir
~O)