Edit Class

Edit Class

This Package | All Packages

Component
  |
  +--Control
    |
    +--Edit
public class Edit
extends Control

Creates a standard Windows edit control. This control supports multiline editing, password character masking, and so forth.

Constructors
Name Description
Edit() Creates a new Edit control, using parent control's current font and color settings.

Methods
Name Description
clear() Clears the edit control.
getAutoSize() Retrieves a booolean value that indicates whether the control is configured to support auto-sizing.
getBorderStyle() Returns the border style of the Edit control.
getCharacterCasing() Retrieves a constant that indicates whether the control modifies the case of characters as they are typed into the control.
getCreateParams() Topic under construction.
getHideSelection() Retrieves a boolean value that indicates whether the control currently hides selected text when the control loses input focus.
getInputKey(int keyData) Topic under construction.
getLines() Retrieves the text in the Edit control, and returns the text in an array of String objects.
getMaxLength() Retrieves the maximum number of characters that can be typed into the Edit control.
getMultiline() Retrieves a boolean value that indicates whether this is a multiline edit control.
getPasswordChar() Retrieves the character used to display passwords for a single-line Edit control.
getPreferredHeight() Retrieves the preferred height of the Edit control.
getReadOnly() Retrieves a boolean value that indicates whether the Edit control is read-only.
getReturnWanted() Retrieves a boolean value that indicates whether a multiline Edit control allows RETURN keys to be processed as input.
getScrollBars() Retrieves the current scroll bar settings for a multiline Edit control.
getSelectedText() Retrieves the currently selected text, and returns it in a String object.
getSelectionEnd() Retrieves the zero-based index of the last character in the current selection.
getSelectionStart() Retrieves the zero-based index of the first character in the current selection.
getTabWanted() Retrieves a boolean value that indicates whether a multiline Edit control allows TAB keys to be processed as input.
getTextAlign() Retrieves a constant that indicates the current text-alignment settings on the control.
getWordWrap() Retrieves a boolean value that indicates whether word-wrapping is set on a multiline Edit control.
onCreateHandle() Overridden to update the newly created handle with the settings of the MaxLength and PasswordChar properties.
select(int start, int end) Selects the text within the specified range.
selectAll() Selects all characters in the Edit control.
setAutoSize(boolean value) Controls whether the height of a single-line Edit control is automatically adjusted when the control's font changes.
setBorderStyle(int value) Sets the border for the Edit control.
setBoundsCore(int x, int y, int width, int height) Overrides Control.setBoundsCore to enforce autoSize.
setCharacterCasing(int value) Specifies whether the case of characters should be modified as they are typed into the Edit control.
setHideSelection(boolean value) Controls whether the Edit control hides selected text when the control loses input focus.
setLines(String[] lines) Initializes a multiline Edit control to contain the contents of an array of String objects, where one string is displayed on each line.
setMaxLength(int value) Specifies the maximum number of characters that can be entered into an Edit control.
setMultiline(boolean value) Specifies whether the Edit control is multiline.
setPasswordChar(char value) Sets the password character for a single-line Edit control.
setReadOnly(boolean value) Specifies whether the edit control is read-only.
setReturnWanted(boolean value) Specifies whether a multiline Edit control processes the RETURN key as an input character.
setScrollBars(int value) Specifies how scroll bars will be displayed in multiline Edit controls.
setSelectedText(String value) Replaces the currently selected text with the specified text.
setSelectionEnd(int value) Specifies the zero-based index of the last character of a text selection in the Edit control.
setSelectionStart(int value) Specifies the zero-based index of the first character of a text selection in the Edit control.
setTabWanted(boolean value) Specifies whether a multiline Edit control processes the TAB key as an input character.
setTextAlign(int value) Specifies the alignment of the text in the Edit control.
setWordWrap(boolean value) Specifies whether word-wrapping is on in a multiline Edit control.

Constructors

Edit.Edit

Syntax
public Edit();
Description

Creates a new Edit control, using parent control's current font and color settings.

Methods

Edit.clear

Syntax
public void clear();
Description

Clears the edit control.

Edit.getAutoSize

Syntax
public boolean getAutoSize();
Return Value

Returns true if the control is currently set to auto-size; otherwise, returns false.

Description

Retrieves a booolean value that indicates whether the control is configured to support auto-sizing. If auto-sizing is on, the size of the control is automatically adjusted when the font is changed.

Edit.getBorderStyle

Syntax
public int getBorderStyle();
Return Value

Returns one of the constants defined in the BorderStyle class. The two possible values are BorderStyle.NONE and BorderStyle.FIXED_SINGLE.

Description

Returns the border style of the Edit control.

Edit.getCharacterCasing

Syntax
public int getCharacterCasing();
Return Value

Returns one of the values defined in the CharacterCasing enumeration.

Description

Retrieves a constant that indicates whether the control modifies the case of characters as they are typed into the control. Characters can be converted to uppercase, lowercase, or not converted.

Edit.getCreateParams

Syntax
protected CreateParams getCreateParams();
Description

Topic under construction.

Overrides

getCreateParams() in Control.

Edit.getHideSelection

Syntax
public boolean getHideSelection();
Return Value

Returns true if the control hides the text; otherwise, returns false.

Description

Retrieves a boolean value that indicates whether the control currently hides selected text when the control loses input focus.

Edit.getInputKey

Syntax
protected boolean getInputKey( int keyData );
Description

Topic under construction.

Overrides

getInputKey(int) in Control.

Edit.getLines

Syntax
public String[] getLines();
Return Value

Returns an arry of strings that contains the contents of the Edit control.

Description

Retrieves the text in the Edit control, and returns the text in an array of String objects. Each line of the text box is returned as a new element in the array. For single-line Edit controls, this array consists of a single element.

Edit.getMaxLength

Syntax
public int getMaxLength();
Return Value

Returns zero or an integer that indicates the maximum character capacity of the control.

Description

Retrieves the maximum number of characters that can be typed into the Edit control. A return value of zero indicates that the maximum capacity of the Edit control is limited only to available memory.

Edit.getMultiline

Syntax
public boolean getMultiline();
Return Value

Returns true if this is a multiline control; otherwise, returns false.

Description

Retrieves a boolean value that indicates whether this is a multiline edit control. By default, the Edit control is a single-line control.

Edit.getPasswordChar

Syntax
public char getPasswordChar();
Return Value

Returns zero or the text of the character used to mask passwords.

Description

Retrieves the character used to display passwords for a single-line Edit control. A return value of zero indicates that the Edit control is not currently being used to enter passwords.

Edit.getPreferredHeight

Syntax
public int getPreferredHeight();
Return Value

Returns an integer indicating the preferred height of the control. To adjust the preferred height, use the adjustHeight method.

Description

Retrieves the preferred height of the Edit control. This calculation is based on the assumption that a single line of text will be displayed in the control.

Edit.getReadOnly

Syntax
public boolean getReadOnly();
Return Value

Returns true if the control is read-only; otherwise, returns false.

Description

Retrieves a boolean value that indicates whether the Edit control is read-only. If the control is read-only,the system beeps when a user attempts to type text into the control.

Edit.getReturnWanted

Syntax
public boolean getReturnWanted();
Return Value

Returns true if the RETURN key can be processed as input; otherwise, returns false.

Description

Retrieves a boolean value that indicates whether a multiline Edit control allows RETURN keys to be processed as input.

Edit.getScrollBars

Syntax
public int getScrollBars();
Return Value

Returns one of the ScrollBars enumeration constants.

Description

Retrieves the current scroll bar settings for a multiline Edit control. These settings are defined in the ScrollBars enumeration.

Edit.getSelectedText

Syntax
public String getSelectedText();
Return Value

Returns the currently selected text if text is selected; otherwise, returns null.

Description

Retrieves the currently selected text, and returns it in a String object.

Edit.getSelectionEnd

Syntax
public int getSelectionEnd();
Return Value

Returns the zero-based index of the last character in the selection

Description

Retrieves the zero-based index of the last character in the current selection.

Edit.getSelectionStart

Syntax
public int getSelectionStart();
Description

Retrieves the zero-based index of the first character in the current selection.

Edit.getTabWanted

Syntax
public boolean getTabWanted();
Return Value

Returns true if TAB keys can be processed as input; otherwise, returns false.

Description

Retrieves a boolean value that indicates whether a multiline Edit control allows TAB keys to be processed as input.

Edit.getTextAlign

Syntax
public int getTextAlign();
Return Value

Returns one of the constants defined in the HorizontalAlignment enumeration.

Description

Retrieves a constant that indicates the current text-alignment settings on the control. This setting applies only to multiline Edit controls.

Edit.getWordWrap

Syntax
public boolean getWordWrap();
Return Value

Returns true if word-wrapping is on; otherwise, returns false.

Description

Retrieves a boolean value that indicates whether word-wrapping is set on a multiline Edit control.

Edit.onCreateHandle

Syntax
protected void onCreateHandle();
Description

Overridden to update the newly created handle with the settings of the MaxLength and PasswordChar properties.

Overrides

onCreateHandle() in Control.

Edit.select

Syntax
public void select( int start, int end );
Parameters
start
The zero-based index of the character with which to begin the selection.
end
The zero-based index of the character with which to end the selection.
Description

Selects the text within the specified range.

Edit.selectAll

Syntax
public void selectAll();
Description

Selects all characters in the Edit control.

Edit.setAutoSize

Syntax
public void setAutoSize( boolean value );
Parameters
value
If set to true, the control is automatically resized when the control's font is changed. Otherwise, the control is not resized.
Description

Controls whether the height of a single-line Edit control is automatically adjusted when the control's font changes.

Edit.setBorderStyle

Syntax
public void setBorderStyle( int value );
Parameters
value
Specifies the BorderStyle constant for the border. The only acceptable values for this parameter are NONE and FIXED_SINGLE.
Description

Sets the border for the Edit control.

Edit.setBoundsCore

Syntax
protected void setBoundsCore( int x, int y, int width, int height );
Parameters
x
The x position of the top-left corner of the Edit control.
y
The y position of the top-left corner of the Edit control.
width
The width of the Edit control.
height
The height of the Edit control.
Description

Overrides Control.setBoundsCore to enforce autoSize.

Overrides

setBoundsCore(int,int,int,int) in Control.

Edit.setCharacterCasing

Syntax
public void setCharacterCasing( int value );
Parameters
One
of the CharacterCasing enumeration constants. Acceptable values for this parameter include CharacterCasing.NORMAL, CharacterCasing.UPPER, and CharacterCasing.LOWER.
Description

Specifies whether the case of characters should be modified as they are typed into the Edit control.

Exceptions

IllegalArgumentException thrown if the specified value is less than CharacterCasing.MIN or greater than CharacterCasing.MAX.

Edit.setHideSelection

Syntax
public void setHideSelection( boolean value );
Parameters
value
A boolean value that indicates whether the selection should be hidden.
Description

Controls whether the Edit control hides selected text when the control loses input focus.

Edit.setLines

Syntax
public void setLines( String[] lines );
Parameters
String[]
The array of String objects to display in the Edit control.
Description

Initializes a multiline Edit control to contain the contents of an array of String objects, where one string is displayed on each line. A carriage return/newline within a single element of the array results in the creation of a new line in the control.

Edit.setMaxLength

Syntax
public void setMaxLength( int value );
Parameters
value
Zero or a number that specifies the character capacity of the control.
Description

Specifies the maximum number of characters that can be entered into an Edit control. A value of zero indicates that the Edit control's capacity should be limited only by available memory.

Edit.setMultiline

Syntax
public void setMultiline( boolean value );
Parameters
value
A boolean value indicating whether the Edit control is a multi-line control.
Description

Specifies whether the Edit control is multiline. By default, the Edit control is a single-line control that ignores ENTER characters.

Edit.setPasswordChar

Syntax
public void setPasswordChar( char value );
Parameters
value
The character to be substituted for the characters that the user types. If you specify a zero, no character masking is applied to text entered in the control; the control functions normally.
Description

Sets the password character for a single-line Edit control.

Edit.setReadOnly

Syntax
public void setReadOnly( boolean value );
Parameters
value
A boolean value that indicates whether the control is read-only.
Description

Specifies whether the edit control is read-only.

Edit.setReturnWanted

Syntax
public void setReturnWanted( boolean value );
Parameters
value
A boolean value that specifies whether RETURN keys should be processed as characters.
Description

Specifies whether a multiline Edit control processes the RETURN key as an input character.

Edit.setScrollBars

Syntax
public void setScrollBars( int value );
Parameters
value
One of the constants defined in the ScrollBars enumeration.
Description

Specifies how scroll bars will be displayed in multiline Edit controls.

Edit.setSelectedText

Syntax
public void setSelectedText( String value );
Parameters
value
The text with which to replace the selected text.
Description

Replaces the currently selected text with the specified text.

Edit.setSelectionEnd

Syntax
public void setSelectionEnd( int value );
Parameters
value
The zero-based index of the character at which the selection ends.
Description

Specifies the zero-based index of the last character of a text selection in the Edit control.

Edit.setSelectionStart

Syntax
public void setSelectionStart( int value );
Parameters
value
The zero-based index of the character at which the selection begins.
Description

Specifies the zero-based index of the first character of a text selection in the Edit control.

Edit.setTabWanted

Syntax
public void setTabWanted( boolean value );
Parameters
value
A boolean value that indicates whether the Edit control should process TAB keys as input characters.
Description

Specifies whether a multiline Edit control processes the TAB key as an input character.

Edit.setTextAlign

Syntax
public void setTextAlign( int value );
Parameters
value
One of the enumeration constants defined in the HorizontalAlign class.
Description

Specifies the alignment of the text in the Edit control. This method applies only to multiline Edit controls.

Edit.setWordWrap

Syntax
public void setWordWrap( boolean value );
Parameters
value
A boolean value that indicates whether word-wrapping is set on this control.
Description

Specifies whether word-wrapping is on in a multiline Edit control.