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

.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. This method is obsolete. Use the Label class instead.
See Also:
Label

.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

.setDrawableCharacter

  public void setDrawableCharacter(char aChar)
Set the character used to display the contents. the default is ANY_CHARACTER.

.drawableCharacter

  public char drawableCharacter()
Return the character used to display the contents

.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. This command is sent each time the user changes the text inside the TextField.

.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 that should receive a command when the textfield commit to a new value. The textfield commit to a new value in the following situations:
  1. The user types Return.
  2. Contents has changed and the user press tab or backtab
  3. 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.

.setCommand

  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.

.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.

.selectRange

  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.

.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)
Overriden to return true. public boolean wantsMouseTrackingEvents() { return true; } /** 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

.keyTyped

  public void keyTyped(KeyEvent event)
Called when a unicode character has been generated after pressing one or more keys.
Overrides:
keyTyped in class View

.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

.canPerformCommand

  public boolean canPerformCommand(String command)
Implements the TextField's ExtendedTarget interface

.performCommand

  public void performCommand(String command,
                             Object data)
Implements the TextField's commands:
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

.willBecomeSelected

  public void willBecomeSelected()
Inform the view that it is about to become the selected view
Overrides:
willBecomeSelected in class View

.canBecomeSelectedView

  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

.nextSelectableView

  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

.previousSelectableView

  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

.copy

  public void copy()
Copys the current selection.

.cut

  public void cut()
Cuts the current selection.

.paste

  public void paste()
Replaces the current selection.

.isScrollable

  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.

.setScrollable

  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.

.formElementText

  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