my dog learned polymorphism*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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
Author

How to add user input in a panel??

Luong Vuong
Greenhorn

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.
 
jQuery in Action, 2nd edition
 
subject: How to add user input in a panel??