Report as inappropriate.
PROJECT TITLE: TextBox01
PURPOSE OF PROJECT:
I am publishing this scenario in support of an article
that I plan to publish on the topic of creating custom
GUIs using Greenfoot. If and when the article is
published, you will find a link to the article at
http://www.dickbaldwin.com/toc.htm
Note that an object of the TextBoxA class has no concept of
focus. Therefore, it must not be used concurrently
with another object that is competing for keystrokes.
This scenario demonstrates the use of an Actor class
that can be used to instantiate a text box
that will accept text input from the user and return
that text as a String object when the getText method is
called on the object.
The getText method returns null if the user hasn't yet
stroked the Enter key. Once the user strokes the
Enter key, the string will be returned the next time
the getText method is called. At that time, the text
box is cleared and made ready to receive new input text
data from the user.
The text box supports the use of the backspace key to
delete text (that has been entered) one character at a
time from the right end of the text string. It does not
support arrow keys or functions keys. If those keys are
stroked, the resulting string will contain the names
of those keys.
AUTHOR: Dick Baldwin
VERSION: 07/13/08
HOW TO START THIS PROJECT: Click the Run button to start.
USER INSTRUCTIONS: Type text into the text box and stroke
the Enter key when you reach the end of the text. The text
that you entered should appear on the Greenfoot Terminal
Window when you stroke the Enter key. The text box should
thenbe cleared, ready to accept new text input. (For an applet,
the text appears in the browser's Java Console)
12685 views / 23 in the last 7 days
3 votes | 0 in the last 7 days
This scenario is a member of: Reusable actors & support classes
Visit the web page for this scenario.
Want to leave a comment? You must first log in.
2013/5/5
2014/10/14