DhEdit Class

DhEdit Class

This Package | All Packages

DhText
  |
  +--DhEdit
public class DhEdit
extends DhText

Represents all edit box functions in an HTML document. Edit boxes can be multiline, single line, or single line password styles. Password edit boxes behave like single line edit boxes, except their contents are masked by the asterisk (*) character.

Constructors
Name Description
DhEdit() Creates an edit box.
DhEdit( String strText ) Creates an edit box.
DhEdit( String strText, boolean multiline ) Creates an edit box.

Methods
Name Description
addOnChange ( DhEventHandler h ) Sets the handler for the onchange event.
addOnSelect ( DhEventHandler h ) Sets the handler for the onselect event.
getCols() Retrieves the width, in characters, of the edit box.
getEnabled() Retrieves the enabled state of the edit box.
getMaxLength() Retrieves the current maximum input length for the edit.
getMultiline() Indicates if the edit control allows editing on more than one line or not.
getPassword() Indicates whether the edit control is being used for password input and must conceal its value.
getReadOnly() Retrieves the current read-only mode.
getRows() Retrieves the current number of rows for a multiline edit box.
getSubmitName( ) Retrieves the name of the edit box, which is used for HTTP form submissions.
getText( ) Retrieves the current text for the edit.
getWordWrap() Retrieves the current wrapping mode.
removeOnChange ( DhEventHandler h ) Removes the handler for the onchange event.
removeOnSelect ( DhEventHandler h ) Removes the handler for the onselect event.
setCols(int cols) Sets the number of columns (characters) for the edit box width.
setEnabled( boolean f) Sets the enabled state of the edit box.
setFocus() Sets the input focus to this edit box
setMaxLength( int nMaxLength ) Sets the current maximum input length of the edit control in characters.
setMultiline(boolean multiline) Indicates if the edit control allows editing on more than one line or not.
setPassword(boolean value) Specifies whether the edit control is being used for password input and must conceal its value.
setReadOnly( boolean fReadOnly ) Sets the read-only mode for the edit control.
setRows(int rows) Sets the number of rows in a multiline edit box.
setSubmitName( String strName ) Sets the name of the edit box.
setText( String strText ) Sets the current text display of the edit box.
setWordWrap(boolean wrap) Sets the wrapping mode for a multiline edit box.

Constructors

DhEdit.DhEdit

Syntax 1
public DhEdit();
Description

Creates an edit box. This constructor creates a blank, single line DhEdit edit box.



Syntax 2
public DhEdit( String strText );
Parameters
strText
The initial text contents of DhEdit.
Description

Creates an edit box. This constructor creates a single line DhEdit edit box.



Syntax 3
public DhEdit( String strText, boolean multiline );
Parameters
strText
The initial text contents of DhEdit.
multiline
Set to true if the edit box has multiple lines, or false if it does not.
Description

Creates an edit box. This constructor creates a DhEdit edit box.

Methods

DhEdit.addOnChange

Syntax
final public void addOnChange ( DhEventHandler h );
Parameters
h
The event handler for this edit box event.
Description

Sets the handler for the onchange event. This event occurs when the user modifies the contents of the edit box, then presses the enter key or moves the focus to a different window or control.

DhEdit.addOnSelect

Syntax
final public void addOnSelect ( DhEventHandler h );
Parameters
h
The event handler for this edit box event.
Description

Sets the handler for the onselect event. This event occurs when the user sets or modifies the selected region of the text box.

DhEdit.getCols

Syntax
public synchronized int getCols();
Return Value

Returns the width in characters.

Description

Retrieves the width, in characters, of the edit box.

DhEdit.getEnabled

Syntax
public boolean getEnabled();
Return Value

Returns true if the box is enabled; returns false if it is not.

Description

Retrieves the enabled state of the edit box.

DhEdit.getMaxLength

Syntax
public int getMaxLength();
Return Value

Returns the maximum input length, in characters.

Description

Retrieves the current maximum input length for the edit. If this value is unset, it may be up to Integer.MAX_VALUE.

DhEdit.getMultiline

Syntax
public boolean getMultiline();
Return Value

Returns true if editing of more than one line is allowed; otherwise, returns false.

Description

Indicates if the edit control allows editing on more than one line or not. By default, only one line of editing is permitted and ENTER characters are ignored.

DhEdit.getPassword

Syntax
public boolean getPassword();
Description

Indicates whether the edit control is being used for password input and must conceal its value.

DhEdit.getReadOnly

Syntax
public boolean getReadOnly();
Return Value

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

Description

Retrieves the current read-only mode.

DhEdit.getRows

Syntax
public synchronized int getRows();
Return Value

Returns number of rows.

Description

Retrieves the current number of rows for a multiline edit box. Always returns 1 if style is not multiline.

DhEdit.getSubmitName

Syntax
public String getSubmitName( );
Return Value

Returns the name of the edit box.

Description

Retrieves the name of the edit box, which is used for HTTP form submissions.

See Also
setSubmitName

DhEdit.getText

Syntax
public synchronized String getText( );
Return Value

Returns the currently displayed string in the edit.

Description

Retrieves the current text for the edit. For ES_PASSWORD style edit boxes, this is the actual string, not the mask.

DhEdit.getWordWrap

Syntax
public boolean getWordWrap();
Return Value

Returns true if wrapping is active, otherwise false.

Description

Retrieves the current wrapping mode.

DhEdit.removeOnChange

Syntax
final public void removeOnChange ( DhEventHandler h );
Parameters
h
The event handler for this edit box event.
Description

Removes the handler for the onchange event. This event occurs when the user modifies the contents of the edit box, then presses the enter key or moves the focus to a different window or control.

DhEdit.removeOnSelect

Syntax
final public void removeOnSelect ( DhEventHandler h );
Parameters
h
The event handler for this edit box event.
Description

Removes the handler for the onselect event. This event occurs when the user sets or modifies the selected region of the text box.

DhEdit.setCols

Syntax
public synchronized void setCols( int cols );
Parameters
cols
The width of the edit box in characters. This number must be greater than zero.
Description

Sets the number of columns (characters) for the edit box width.

DhEdit.setEnabled

Syntax
public void setEnabled( boolean f );
Parameters
f
Set to true to enable the edit box; set to false disabled it.
Description

Sets the enabled state of the edit box.

DhEdit.setFocus

Syntax
public void setFocus();
Description

Sets the input focus to this edit box

DhEdit.setMaxLength

Syntax
public void setMaxLength( int nMaxLength );
Parameters
nMaxLength
Maximum input length, in characters.
Description

Sets the current maximum input length of the edit control in characters. This value is independent of the current column width, and only applies to password or single line edut boxes. Strings set from code can exceed this length; only user input is restricted.

DhEdit.setMultiline

Syntax
public void setMultiline( boolean multiline );
Parameters
value
Set to true if editing of more than one line is allowed; otherwise, set to false.
Description

Indicates if the edit control allows editing on more than one line or not. By default, only one line of editing is permitted and ENTER characters are ignored.

DhEdit.setPassword

Syntax
public void setPassword( boolean value );
Parameters
value
Set to true if the control is used to enter passwords; otherwise, set to false.
Description

Specifies whether the edit control is being used for password input and must conceal its value. Password controls must be single line, so if this is set to true, then the Multiline property becomes false.

DhEdit.setReadOnly

Syntax
public void setReadOnly( boolean fReadOnly );
Parameters
fReadOnly
Set to true for read-only or false for read-write.
Description

Sets the read-only mode for the edit control.

DhEdit.setRows

Syntax
public void setRows( int rows );
Parameters
rows
the number of rows
Description

Sets the number of rows in a multiline edit box.

Exceptions

IllegalArgumentException Thrown if rows is less than or equal to 0

IllegalArgumentException Thrown if rows is greater than 1 and style is not multiline.

DhEdit.setSubmitName

Syntax
public void setSubmitName( String strName );
Parameters
strName
The name to assign the control. This should be unique on the form.
Description

Sets the name of the edit box. Useful when submitting edit box content through an HTML form.

DhEdit.setText

Syntax
public synchronized void setText( String strText );
Parameters
strText
the text to display.
Description

Sets the current text display of the edit box.

DhEdit.setWordWrap

Syntax
public void setWordWrap( boolean wrap );
Parameters
wrap
true for wrapping, false for no wrapping.
Description

Sets the wrapping mode for a multiline edit box.