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.Target,
{
/* Fields
*/
public final static java.lang.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 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 int cursorForPoint(int, int);
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 boolean drawsDropShadow();
public void encode(Encoder);
public TextFilter filter();
public void finishDecoding();
public Font font();
public boolean hasInsertionPoint();
public boolean hasSelection();
public int intValue();
public boolean isBeingEdited();
public boolean isEditable();
public boolean isEmpty();
public boolean isSelectable();
public boolean isTransparent();
public int justification();
public void keyDown(KeyEvent);
public int leftIndent();
public Size minSize();
public boolean mouseDown(MouseEvent);
public void mouseDragged(MouseEvent);
public void mouseUp(MouseEvent);
public TextFieldOwner owner();
public void pauseFocus();
public void performCommand(String, Object);
public void replaceRangeWithString(Range, String);
public void resumeFocus();
public int rightIndent();
public void selectRange(Range);
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 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 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 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
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
createLabel
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.
createLabel
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.
leftIndent
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.
rightIndent
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.
minSize
public Size minSize()
- Returns the TextField's minimum size.
- Overrides:
- minSize in class View
setFont
public void setFont(Font aFont)
- Sets the TextField's Font and redraws the TextField. The default Font
is Font.defaultFont().
- See Also:
- defaultFont
font
public Font font()
- Returns the TextField's font.
- See Also:
- setFont
setTextColor
public void setTextColor(Color aColor)
- Sets the Color of the TextField's text and redraws the TextField.
Default text color is Color.black.
textColor
public Color textColor()
- Returns the TextField's text Color.
- See Also:
- setTextColor
setBackgroundColor
public void setBackgroundColor(Color aColor)
- Sets the TextField's background Color and redraws the TextField.
Default background Color is Color.white.
backgroundColor
public Color backgroundColor()
- Returns the TextField's background Color.
- See Also:
- setBackgroundColor
setSelectionColor
public void setSelectionColor(Color aColor)
- Sets the Color the TextField uses to indicate selection and redraws the
TextField. Default selection Color is Color.lightGray.
selectionColor
public Color selectionColor()
- Returns the TextField's selection Color.
- See Also:
- setSelectionColor
setCaretColor
public void setCaretColor(Color aColor)
- Sets the Color of the TextField's caret. Default is Color.black.
caretColor
public Color caretColor()
- Returns the TextField's caret Color.
- See Also:
- setCaretColor
setBorder
public void setBorder(Border newBorder)
- Sets the Border the TextField draws around its perimeter.
- See Also:
- Border
border
public Border border()
- Returns the TextField's Border.
- See Also:
- setBorder
setDrawsDropShadow
public void setDrawsDropShadow(boolean flag)
- Configures the TextField to draw its text with a drop shadow.
drawsDropShadow
public boolean drawsDropShadow()
- Returns true if the TextField draws its text with a drop shadow.
- See Also:
- setDrawsDropShadow
setJustification
public void setJustification(int aJustification)
- Sets the justification (Graphics.LEFT_JUSTIFIED,
Graphics.CENTERED, Graphics.RIGHT_JUSTIFIED) the
TextField uses to draw its text.
justification
public int justification()
- Returns the justification the TextField uses to draw its text.
setTransparent
public void setTransparent(boolean flag)
- Overridden to automatically remove the TextField's Border if
flag is true.
isTransparent
public boolean isTransparent()
- Overridden to return true if the TextField is transparent.
- Overrides:
- isTransparent in class View
- See Also:
- setTransparent
setSelectable
public void setSelectable(boolean flag)
- Configures the TextField to allow the user to select its text.
isSelectable
public boolean isSelectable()
- Returns true if the TextField allows the user to select its
text.
- See Also:
- setSelectable
wantsAutoscrollEvents
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
setWrapsContents
public void setWrapsContents(boolean flag)
- Configures the TextField to wrap its contents if too long to fit
on a single line.
wrapsContents
public boolean wrapsContents()
- Returns true if the TextField wraps its contents if too long to
fit on a single line.
- See Also:
- setWrapsContents
setEditable
public void setEditable(boolean aFlag)
- Configures the TextField to allow the user to edit its text.
isEditable
public boolean isEditable()
- Returns true if the TextField is editable.
- See Also:
- setEditable
isBeingEdited
public boolean isBeingEdited()
- Returns true if the TextField's contents are currently being
edited.
cursorForPoint
public int cursorForPoint(int x,
int y)
- Overridden to return TEXT_CURSOR when the TextField is selectable or
editable.
- Overrides:
- cursorForPoint in class View
setOwner
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
owner
public TextFieldOwner owner()
- Returns the TextField's owner.
- See Also:
- setOwner
setFilter
public void setFilter(TextFilter aFilter)
- Sets the TextField's filter, the object that inspects each key
Event received by the TextField.
- See Also:
- TextFilter
filter
public TextFilter filter()
- Returns the TextField's text filter.
- See Also:
- setFilter
setContentsChangedCommandAndTarget
public void setContentsChangedCommandAndTarget(String aCommand,
Target aTarget)
- Sets the Target and the command it should receive when the TextField's
contents change because editing has ended.
contentsChangedTarget
public Target contentsChangedTarget()
- Returns the contents changed Target.
- See Also:
- setContentsChangedCommandAndTarget
contentsChangedCommand
public String contentsChangedCommand()
- Returns the contents changed command.
- See Also:
- setContentsChangedCommandAndTarget
setTabField
public void setTabField(TextField aTextField)
- Sets the TextField whose text is selected when the TextField
receives a Return or Tab key Event.
tabField
public TextField tabField()
- Returns the TextField whose text is selected when the TextField
receives a Return or Tab key Event.
- See Also:
- setTabField
setBacktabField
public void setBacktabField(TextField aTextField)
- Sets the TextField whose text is selected when the TextField
receives a Backtab key Event.
backtabField
public TextField backtabField()
- Returns the TextField whose text is selected when the TextField
receives a Backtab key Event.
- See Also:
- setBacktabField
setTarget
public void setTarget(Target aTarget)
- Sets the Target for the TextField's Return key Event.
setCommand
public void setCommand(String aCommand)
- Sets the command the Target should receive when the TextField
receives a Return key Event.
target
public Target target()
- Returns the Return Target.
- See Also:
- setTarget
command
public String command()
- Returns the Return command.
- See Also:
- setCommand
setStringValue
public void setStringValue(String aString)
- Sets the contents of the TextField to aString
stringValue
public String stringValue()
- Returns the TextField's contents.
- See Also:
- setStringValue
replaceRangeWithString
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.
stringForRange
public String stringForRange(Range aRange)
- Returns the string included in aRange.
selectedStringValue
public String selectedStringValue()
- Returns the selected portion of the TextField's contents. If none,
returns the empty string.
- See Also:
- stringValue
setIntValue
public void setIntValue(int anInt)
- Sets the contents of the TextField to the string version of
anInt.
intValue
public int intValue()
- Returns the integer value of the TextField's contents, or 0 if
not a number.
isEmpty
public boolean isEmpty()
- Returns true if the TextField contains no text.
charCount
public int charCount()
- Returns the number of characters the TextField contains.
baseline
public int baseline()
- Returns the baseline of the first line of text.
selectRange
public void selectRange(Range aRange)
- Selects characters in the Range aRange, unless the TextField is
not selectable.
selectText
public void selectText()
- Selects the TextField's contents, unless it is not selectable.
- See Also:
- selectRange
setInsertionPoint
public void setInsertionPoint(int position)
- Places the TextField's insertion point at position, unless
the TextField is not selectable.
selectedRange
public Range selectedRange()
- Returns a Range containing the current selection. If no selection
exists, this method returns a null range.
hasSelection
public boolean hasSelection()
- Returns true if the TextField has a selection.
hasInsertionPoint
public boolean hasInsertionPoint()
- Returns true if the TextField has an insertion point.
xPositionOfCharacter
public int xPositionOfCharacter(int charNumber)
- Returns the X-coordinate of character number charNumber.
charNumberForPoint
public int charNumberForPoint(int x)
- Returns the character number for X-coordinate x.
drawViewStringAt
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.
drawViewInterior
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.
drawViewBorder
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.
drawView
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
drawInterior
public void drawInterior()
- Redraws the TextField's interior.
mouseDown
public boolean mouseDown(MouseEvent event)
- Overridden to process mouse Events within the TextField.
- Overrides:
- mouseDown in class View
mouseDragged
public void mouseDragged(MouseEvent event)
- Overridden to process mouse Events within the TextField.
- Overrides:
- mouseDragged in class View
mouseUp
public void mouseUp(MouseEvent event)
- Overridden to process mouse Events within the TextField.
- Overrides:
- mouseUp in class View
keyDown
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
setFocusedView
public void setFocusedView()
- Override this method to start an editing session if necessary
- Overrides:
- setFocusedView in class View
startFocus
public void startFocus()
- Overridden to notify the TextField it has become the focus of
KeyEvents.
- Overrides:
- startFocus in class View
stopFocus
public void stopFocus()
- Overridden to notify the TextField it has ceased being the focus of
KeyEvents.
- Overrides:
- stopFocus in class View
pauseFocus
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
resumeFocus
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
cancelEditing
public void cancelEditing()
- Causes the TextField to cancel editing by discarding any changes
that the user made.
completeEditing
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
performCommand
public void performCommand(String command,
Object data)
- Implements the TextField's commands:
- SELECT_TEXT - calls the selectText() method.
- See Also:
- selectText
describeClassInfo
public void describeClassInfo(ClassInfo info)
- Describes the TextField class' information.
- Overrides:
- describeClassInfo in class View
- See Also:
- describeClassInfo
encode
public void encode(Encoder encoder) throws CodingException
- Encodes the TextField instance.
- Overrides:
- encode in class View
- See Also:
- decode
decode
public void decode(Decoder decoder) throws CodingException
- Decodes the TextField instance.
- Overrides:
- decode in class View
- See Also:
- decode
finishDecoding
public void finishDecoding() throws CodingException
- Finishes the TextField instance decoding.
- Overrides:
- finishDecoding in class View
- See Also:
- finishDecoding
All Packages Class Hierarchy This Package Previous Next Index