Class TextField
All Packages Class Hierarchy This Package Previous Next Index
Class TextField
public class netscape.application.TextField
extends netscape.application.View
implements netscape.application.ExtendedTarget,
netscape.application.FormElement
{
/* Fields
*/
public static char ANY_CHARACTER;
public final static String SELECT_TEXT;
/* Constructors
*/
public TextField();
public TextField(Rect);
public TextField(int, int, int, int);
/* Methods
*/
public static TextField createLabel(String, Font);
public static TextField createLabel(String);
public Color backgroundColor();
public TextField backtabField();
public int baseline();
public Border border();
public boolean canBecomeSelectedView();
public boolean canPerformCommand(String);
public void cancelEditing();
public Color caretColor();
public int charCount();
public int charNumberForPoint(int);
public String command();
public void completeEditing();
public String contentsChangedCommand();
public Target contentsChangedTarget();
public void copy();
public int cursorForPoint(int, int);
public void cut();
public void decode(Decoder);
public void describeClassInfo(ClassInfo);
public void drawInterior();
public void drawView(Graphics);
public void drawViewBorder(Graphics);
public void drawViewInterior(Graphics, Rect);
public void drawViewStringAt(Graphics, String, int, int);
public char drawableCharacter();
public boolean drawsDropShadow();
public void encode(Encoder);
public TextFilter filter();
public void finishDecoding();
public Font font();
public String formElementText();
public boolean hasInsertionPoint();
public boolean hasSelection();
public int intValue();
public boolean isBeingEdited();
public boolean isEditable();
public boolean isEmpty();
public boolean isScrollable();
public boolean isSelectable();
public boolean isTransparent();
public int justification();
public void keyDown(KeyEvent);
public void keyTyped(KeyEvent);
public int leftIndent();
public Size minSize();
public boolean mouseDown(MouseEvent);
public void mouseDragged(MouseEvent);
public void mouseUp(MouseEvent);
public View nextSelectableView();
public TextFieldOwner owner();
public void paste();
public void pauseFocus();
public void performCommand(String, Object);
public View previousSelectableView();
public void replaceRangeWithString(Range, String);
public void resumeFocus();
public int rightIndent();
public void selectRange(Range);
protected void selectRange(int, int);
public void selectText();
public Range selectedRange();
public String selectedStringValue();
public Color selectionColor();
public void setBackgroundColor(Color);
public void setBacktabField(TextField);
public void setBorder(Border);
public void setCaretColor(Color);
public void setCommand(String);
public void setContentsChangedCommandAndTarget(String, Target);
public void setDrawableCharacter(char);
public void setDrawsDropShadow(boolean);
public void setEditable(boolean);
public void setFilter(TextFilter);
public void setFocusedView();
public void setFont(Font);
public void setInsertionPoint(int);
public void setIntValue(int);
public void setJustification(int);
public void setOwner(TextFieldOwner);
public void setScrollable(boolean);
public void setSelectable(boolean);
public void setSelectionColor(Color);
public void setStringValue(String);
public void setTabField(TextField);
public void setTarget(Target);
public void setTextColor(Color);
public void setTransparent(boolean);
public void setWrapsContents(boolean);
public void startFocus();
public void stopFocus();
public String stringForRange(Range);
public String stringValue();
public TextField tabField();
public Target target();
public Color textColor();
public boolean wantsAutoscrollEvents();
public void willBecomeSelected();
public boolean wrapsContents();
public int xPositionOfCharacter(int);
}
View subclass that displays and, optionally, lets the user edit a mono-
font string.
TextFields have owners that are notified of important events within the
TextField, such as the completion of an editing session. They also have
filters that can filter or process each key event received by the
TextField. On certain events, such as receiving a tab key, the TextField
can send a command to a Target interested in reacting to that event.
Fields
ANY_CHARACTER
public static char ANY_CHARACTER
- Constant to indicate that any character can be displayed
@see setDrawableCharacter()
SELECT_TEXT
public final static String SELECT_TEXT
- Command to select the TextField's entire contents.
Constructors
.TextField
public TextField()
- Constructs a TextField with origin (0, 0) and zero
width and height.
.TextField
public TextField(Rect rect)
- Constructs a TextField with bounds rect.
.TextField
public TextField(int x,
int y,
int width,
int height)
- Constructs a TextField with
bounds (x, y, width, height).
Methods
public static TextField createLabel(String string,
Font font)
- Creates a new TextField that is suitable for use as a "label": it has
no Border, is transparent, and is not editable or selectable. The
label displays string using font.
This method is obsolete. Use the Label class instead.
- See Also:
- Label
public static TextField createLabel(String string)
- Creates a new TextField that is suitable for use as a "label": it has
no Border, is transparent, and is not editable or selectable. The label
displays string using the default font.
public int leftIndent()
- Returns the distance between the interior edge of the TextField's
left border and the first character. By default, this method returns
the left margin of the TextField's Border.
public int rightIndent()
- Returns the distance between the interior edge of the TextField's right
border and the last character. By default, returns the right margin
plus 1 of the TextField's Border.
public Size minSize()
- Returns the TextField's minimum size.
- Overrides:
- minSize in class View
public void setDrawableCharacter(char aChar)
- Set the character used to display the contents.
the default is ANY_CHARACTER.
public char drawableCharacter()
- Return the character used to display the contents
public void setFont(Font aFont)
- Sets the TextField's Font and redraws the TextField. The default Font
is Font.defaultFont().
- See Also:
- defaultFont
public Font font()
- Returns the TextField's font.
- See Also:
- setFont
public void setTextColor(Color aColor)
- Sets the Color of the TextField's text and redraws the TextField.
Default text color is Color.black.
public Color textColor()
- Returns the TextField's text Color.
- See Also:
- setTextColor
public void setBackgroundColor(Color aColor)
- Sets the TextField's background Color and redraws the TextField.
Default background Color is Color.white.
public Color backgroundColor()
- Returns the TextField's background Color.
- See Also:
- setBackgroundColor
public void setSelectionColor(Color aColor)
- Sets the Color the TextField uses to indicate selection and redraws the
TextField. Default selection Color is Color.lightGray.
public Color selectionColor()
- Returns the TextField's selection Color.
- See Also:
- setSelectionColor
public void setCaretColor(Color aColor)
- Sets the Color of the TextField's caret. Default is Color.black.
public Color caretColor()
- Returns the TextField's caret Color.
- See Also:
- setCaretColor
public void setBorder(Border newBorder)
- Sets the Border the TextField draws around its perimeter.
- See Also:
- Border
public Border border()
- Returns the TextField's Border.
- See Also:
- setBorder
public void setDrawsDropShadow(boolean flag)
- Configures the TextField to draw its text with a drop shadow.
public boolean drawsDropShadow()
- Returns true if the TextField draws its text with a drop shadow.
- See Also:
- setDrawsDropShadow
public void setJustification(int aJustification)
- Sets the justification (Graphics.LEFT_JUSTIFIED,
Graphics.CENTERED, Graphics.RIGHT_JUSTIFIED) the
TextField uses to draw its text.
public int justification()
- Returns the justification the TextField uses to draw its text.
public void setTransparent(boolean flag)
- Overridden to automatically remove the TextField's Border if
flag is true.
public boolean isTransparent()
- Overridden to return true if the TextField is transparent.
- Overrides:
- isTransparent in class View
- See Also:
- setTransparent
public void setSelectable(boolean flag)
- Configures the TextField to allow the user to select its text.
public boolean isSelectable()
- Returns true if the TextField allows the user to select its
text.
- See Also:
- setSelectable
public boolean wantsAutoscrollEvents()
- Overridden to return true if the TextField wants to
automatically receive mouse dragged Events when the user clicks and
drags outside of its bounds.
- Overrides:
- wantsAutoscrollEvents in class View
public void setWrapsContents(boolean flag)
- Configures the TextField to wrap its contents if too long to fit
on a single line.
public boolean wrapsContents()
- Returns true if the TextField wraps its contents if too long to
fit on a single line.
- See Also:
- setWrapsContents
public void setEditable(boolean aFlag)
- Configures the TextField to allow the user to edit its text.
public boolean isEditable()
- Returns true if the TextField is editable.
- See Also:
- setEditable
public boolean isBeingEdited()
- Returns true if the TextField's contents are currently being
edited.
public int cursorForPoint(int x,
int y)
- Overridden to return TEXT_CURSOR when the TextField is selectable or
editable.
- Overrides:
- cursorForPoint in class View
public void setOwner(TextFieldOwner owner)
- Sets the TextField's owner, the object that it notifies of important
events such as receiving a new key Event.
- See Also:
- TextFieldOwner
public TextFieldOwner owner()
- Returns the TextField's owner.
- See Also:
- setOwner
public void setFilter(TextFilter aFilter)
- Sets the TextField's filter, the object that inspects each key
Event received by the TextField.
- See Also:
- TextFilter
public TextFilter filter()
- Returns the TextField's text filter.
- See Also:
- setFilter
public void setContentsChangedCommandAndTarget(String aCommand,
Target aTarget)
- Sets the Target and the command it should receive when the TextField's
contents change. This command is sent each time the user changes the
text inside the TextField.
public Target contentsChangedTarget()
- Returns the contents changed Target.
- See Also:
- setContentsChangedCommandAndTarget
public String contentsChangedCommand()
- Returns the contents changed command.
- See Also:
- setContentsChangedCommandAndTarget
public void setTabField(TextField aTextField)
- Sets the TextField whose text is selected when the TextField
receives a Return or Tab key Event.
public TextField tabField()
- Returns the TextField whose text is selected when the TextField
receives a Return or Tab key Event.
- See Also:
- setTabField
public void setBacktabField(TextField aTextField)
- Sets the TextField whose text is selected when the TextField
receives a Backtab key Event.
public TextField backtabField()
- Returns the TextField whose text is selected when the TextField
receives a Backtab key Event.
- See Also:
- setBacktabField
public void setTarget(Target aTarget)
- Sets the Target that should receive a command when the textfield
commit to a new value. The textfield commit to a new value in the
following situations:
- The user types Return.
- Contents has changed and the user press tab or backtab
- Contents has changed and the textfield loses focus
If a more precise understanding of why the textfield is ending
the editing session is required, you need to use TextFieldOwner.
public void setCommand(String aCommand)
- Sets the command the Target should receive when the
editing ends. The editing ends when the user types return,
tab, backtab or select something else.
public Target target()
- Returns the Return Target.
- See Also:
- setTarget
public String command()
- Returns the Return command.
- See Also:
- setCommand
public void setStringValue(String aString)
- Sets the contents of the TextField to aString
public String stringValue()
- Returns the TextField's contents.
- See Also:
- setStringValue
public void replaceRangeWithString(Range aRange,
String aString)
- Replaces the string enclosed by aRange with aString. If
aRange is a null range, this method inserts aString into
the text. If aString is null or the empty string, this
method removes the text defined by aRange.
public String stringForRange(Range aRange)
- Returns the string included in aRange.
public String selectedStringValue()
- Returns the selected portion of the TextField's contents. If none,
returns the empty string.
- See Also:
- stringValue
public void setIntValue(int anInt)
- Sets the contents of the TextField to the string version of
anInt.
public int intValue()
- Returns the integer value of the TextField's contents, or 0 if
not a number.
public boolean isEmpty()
- Returns true if the TextField contains no text.
public int charCount()
- Returns the number of characters the TextField contains.
public int baseline()
- Returns the baseline of the first line of text.
public void selectRange(Range aRange)
- Selects characters in the Range aRange, unless the TextField is
not selectable.
protected void selectRange(int start,
int stop)
- Selects characters start through stop of the
TextField's contents, unless the TextField is not selectable.
Override this method if you need to know when the selection changed.
public void selectText()
- Selects the TextField's contents, unless it is not selectable.
- See Also:
- selectRange
public void setInsertionPoint(int position)
- Places the TextField's insertion point at position, unless
the TextField is not selectable.
public Range selectedRange()
- Returns a Range containing the current selection. If no selection
exists, this method returns a null range.
public boolean hasSelection()
- Returns true if the TextField has a selection.
public boolean hasInsertionPoint()
- Returns true if the TextField has an insertion point.
public int xPositionOfCharacter(int charNumber)
- Returns the X-coordinate of character number charNumber.
public int charNumberForPoint(int x)
- Returns the character number for X-coordinate x.
public void drawViewStringAt(Graphics g,
String aString,
int x,
int y)
- Draws the String at position (x, y). You never call this
method directly, but should override to produce custom string drawing.
public void drawViewInterior(Graphics g,
Rect interiorRect)
- Draws the portion of the TextField's interior specified by
interiorRect. Calls drawViewStringAt() to draw the text.
You never call this method directly, but should override to produce
custom TextField drawing.
public void drawViewBorder(Graphics g)
- Draws the TextField's border using its Border. You never call this
method directly, but should override to produce custom border drawing.
public void drawView(Graphics g)
- Draws the TextField. Calls drawViewBorder() and
drawViewInterior(). You never call this method directly - call
the TextField's draw() method to draw the TextField.
- Overrides:
- drawView in class View
public void drawInterior()
- Redraws the TextField's interior.
public boolean mouseDown(MouseEvent event)
- Overriden to return true.
public boolean wantsMouseTrackingEvents() {
return true;
}
/** Overridden to process mouse Events within the TextField.
- Overrides:
- mouseDown in class View
public void mouseDragged(MouseEvent event)
- Overridden to process mouse Events within the TextField.
- Overrides:
- mouseDragged in class View
public void mouseUp(MouseEvent event)
- Overridden to process mouse Events within the TextField.
- Overrides:
- mouseUp in class View
public void keyDown(KeyEvent event)
- Overridden to process key Events within the TextField. If you want
to process or filter key Events yourself, implement the TextFilter
interface and set yourself as the TextField's filter.
- Overrides:
- keyDown in class View
- See Also:
- setFilter
public void keyTyped(KeyEvent event)
- Called when a unicode character has been generated after pressing one or more
keys.
- Overrides:
- keyTyped in class View
public void setFocusedView()
- Override this method to start an editing session if necessary
- Overrides:
- setFocusedView in class View
public void startFocus()
- Overridden to notify the TextField it has become the focus of
KeyEvents.
- Overrides:
- startFocus in class View
public void stopFocus()
- Overridden to notify the TextField it has ceased being the focus of
KeyEvents.
- Overrides:
- stopFocus in class View
public void pauseFocus()
- Overridden to notify the TextField that it has ceased being the focus
of KeyEvents, but that it will regain focus when the user clicks on
its InternalWindow.
- Overrides:
- pauseFocus in class View
public void resumeFocus()
- Overridden to notify the TextField it has become the focus of
KeyEvents, because the user clicked on its InternalWindow.
- Overrides:
- resumeFocus in class View
public void cancelEditing()
- Causes the TextField to cancel editing by discarding any changes
that the user made.
public void completeEditing()
- Causes the TextField to complete any editing by retaining all
changes the user made to the TextField's text.
- See Also:
- cancelEditing
public boolean canPerformCommand(String command)
- Implements the TextField's ExtendedTarget interface
public void performCommand(String command,
Object data)
- Implements the TextField's commands:
- SELECT_TEXT - calls the selectText() method.
- See Also:
- selectText
public void describeClassInfo(ClassInfo info)
- Describes the TextField class' information.
- Overrides:
- describeClassInfo in class View
- See Also:
- describeClassInfo
public void encode(Encoder encoder) throws CodingException
- Encodes the TextField instance.
- Overrides:
- encode in class View
- See Also:
- decode
public void decode(Decoder decoder) throws CodingException
- Decodes the TextField instance.
- Overrides:
- decode in class View
- See Also:
- decode
public void finishDecoding() throws CodingException
- Finishes the TextField instance decoding.
- Overrides:
- finishDecoding in class View
- See Also:
- finishDecoding
public void willBecomeSelected()
- Inform the view that it is about to become the selected view
- Overrides:
- willBecomeSelected in class View
public boolean canBecomeSelectedView()
- Return whether this view can become the selected view
when the user is moving from view to views with the keyboard
Returns true
- Overrides:
- canBecomeSelectedView in class View
public View nextSelectableView()
- Return the View that should become selected when the user
press the tab key. If the result is null, the keyboard UI
system will select the next available view.
The default implementation returns the tabField.
- Overrides:
- nextSelectableView in class View
public View previousSelectableView()
- Return the View that should become selected when the user
press the backtab key. If the result is null, the keyboard UI
system will select the next available view.
The default implementation return the backtabField.
- Overrides:
- previousSelectableView in class View
public void copy()
- Copys the current selection.
public void cut()
- Cuts the current selection.
public void paste()
- Replaces the current selection.
public boolean isScrollable()
- By default TextFields will scroll as the user types, so they can see
what they are typing. This flag indicates if this scrolling should
occur. If isScrollable returns false, the content area that
the user is typing in will not be scrolled. Additionally, if user
drags a selection, the selection will not cause the text to scroll.
public void setScrollable(boolean value)
- By default TextFields will scroll as the user types, so they can see
what they are typing. This flag indicates if this scrolling should
occur.
public String formElementText()
- Implementation of the FormElement interface
All Packages Class Hierarchy This Package Previous Next Index
Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Oct 1997