We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Text Fields
Page Index Toggle Pages: 1
Text Fields (Read 2062 times)
Text Fields
Jun 14th, 2006, 3:53pm
 
Wich would be the straightest way to perform simple text fields in Processing?

Re: Text Fields
Reply #1 - Jun 15th, 2006, 12:05am
 
import java.awt.*;

TextField textField = new TextField("type here", 16);
color bg = color(33,33,33,255);

void setup(){
 size(200,200);
 add(textField);
}

void draw(){
 background(bg);
}
Re: Text Fields
Reply #2 - Jun 15th, 2006, 2:58pm
 
OK, so I can import any installed java classes as usual in regular Java. Didn't know that. Thank you very much Kirton.
Re: Text Fields
Reply #3 - Jun 15th, 2006, 10:26pm
 
Sorry to be a pest...
Unless I missed a post stating otherwise, Fry addressed this point a few months back; here's the essential quote:
" processing code is preprocessed into java, so most things just work.. the exception is generally anything using java.awt.* or java.swing.*, which should be avoided."

Re: Text Fields
Reply #4 - Jun 16th, 2006, 12:21am
 
Thanks irag.

I'm just getting into the discourse and have been trying to keep up, but looks like I missed fry's post about the awt/swing issue.

It worked for me in this case, but what then would you suggest for textfields?

k
Re: Text Fields
Reply #5 - Jun 16th, 2006, 8:40pm
 
I had a student this year who attempted to code a textField of sorts in Processing. Although her focus was more on self-expression than developing anything "useful"; it was a good academic exercise. It's probably best to let Processing be what it was designed to be-a wonderfully user-friendly graphics component.

I assume you know Java, so you might try building a Swing app and sticking your TextField and PApplet in a JFrame layout, as separate components.

Fry says:
"...an applet is just a component and you can add it to a swing layout the way you would any other awt component. as of recent releases, PApplet handles resizing itself properly when the layout manager asks it to.

noLoop() and redraw() are important in these situations, so that you don't have several animation threads running that need not be, and so that they aren't fighting with each other.
"

There's more info scattered around the board about this topic.
Re: Text Fields
Reply #6 - Jun 21st, 2006, 3:35am
 
Hey Irag,

I'm actually fairly new to programming, I picked up Processing in January and as a result took a course in Java, so I'm still learning. Building Swing layouts and applications is the next step for me.

Cheers,
tk
Page Index Toggle Pages: 1