This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to add user input in a panel?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add user input in a panel??" Watch "How to add user input in a panel??" New topic

How to add user input in a panel??

Luong Vuong

Joined: Jan 20, 2007
Posts: 8
hi i have created a panel:

Is there anyway of using the panel to accept user input, in this case the number of triangles.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

Sure, of course! You can accept input in a TextField.

Moving to Swing/AWT/JFace/SWT.

[Jess in Action][AskingGoodQuestions]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
(looks like you may be using awt only).

a TextField is the normal way to handle user input, but you need to include
a fair amount of error handling. If the range of 'number of triangles' is limited,
it might be easier for you to use a java.awt.Choice, where the user can select
the number from a range you have set.
It is sorta covered in the JavaRanch Style Guide.
subject: How to add user input in a panel??
Similar Threads
Getting wrong answers for conversion
User Input Parameters
Help w/ Data Input Error
Can varying input to a specified textField's ActionListener elicit corresponding varying output
So difficult to use Layout managers!!!