javax.swing.text.html

Class FormView

Implemented Interfaces:
ActionListener, EventListener, SwingConstants

public class FormView
extends ComponentView
implements ActionListener

Component decorator that implements the view interface for form elements, <input>, <textarea>, and <select>. The model for the component is stored as an attribute of the the element (using StyleConstants.ModelAttribute), and is used to build the component of the view. The type of the model is assumed to of the type that would be set by HTMLDocument.HTMLReader.FormAction. If there are multiple views mapped over the document, they will share the embedded component models.

The following table shows what components get built by this view.

Element TypeComponent built
input, type buttonJButton
input, type checkboxJCheckBox
input, type imageJButton
input, type passwordJPasswordField
input, type radioJRadioButton
input, type resetJButton
input, type submitJButton
input, type textJTextField
select, size > 1 or multiple attribute definedJList in a JScrollPane
select, size unspecified or 1JComboBox
textareaJTextArea in a JScrollPane
input, type fileJTextField

Nested Class Summary

protected class
FormView.MouseEventListener
MouseEventListener class to handle form submissions when an input with type equal to image is clicked on.

Field Summary

static @Deprecated
StringRESET
Deprecated. As of 1.3, value comes from UIManager UIManager property FormView.resetButtonText
static @Deprecated
StringSUBMIT
Deprecated. As of 1.3, value now comes from UIManager property FormView.submitButtonText

Fields inherited from class javax.swing.text.View

BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS

Fields inherited from interface javax.swing.SwingConstants

BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST

Constructor Summary

FormView(Element elem)
Creates a new FormView object.

Method Summary

void
actionPerformed(ActionEvent evt)
Responsible for processeing the ActionEvent.
protected Component
createComponent()
Create the component.
float
getMaximumSpan(int axis)
Determines the maximum span for this view along an axis.
protected void
imageSubmit(String imageData)
This method is called to submit a form in response to a click on an image -- an <INPUT> form element of type "image".
protected void
submitData(String data)
This method is responsible for submitting the form data.

Methods inherited from class javax.swing.text.ComponentView

createComponent, getAlignment, getComponent, getMaximumSpan, getMinimumSpan, getPreferredSpan, modelToView, paint, setParent, viewToModel

Methods inherited from class javax.swing.text.View

Shape modelToView, append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getPreferredSpan, getResizeWeight, getStartOffset, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, insertUpdate, int viewToModel, isVisible, modelToView, modelToView, paint, preferenceChanged, remove, removeAll, removeUpdate, replace, setParent, setSize, updateChildren, updateLayout, viewToModel

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

StringRESET

public static final @Deprecated StringRESET

Deprecated. As of 1.3, value comes from UIManager UIManager property FormView.resetButtonText

If a value attribute is not specified for a FORM input element of type "reset", then this default string is used.

StringSUBMIT

public static final @Deprecated StringSUBMIT

Deprecated. As of 1.3, value now comes from UIManager property FormView.submitButtonText

If a value attribute is not specified for a FORM input element of type "submit", then this default string is used.

Constructor Details

FormView

public FormView(Element elem)
Creates a new FormView object.
Parameters:
elem - the element to decorate

Method Details

actionPerformed

public void actionPerformed(ActionEvent evt)
Responsible for processeing the ActionEvent. If the element associated with the FormView, has a type of "submit", "reset", "text" or "password" then the action is processed. In the case of a "submit" the form is submitted. In the case of a "reset" the form is reset to its original state. In the case of "text" or "password", if the element is the last one of type "text" or "password", the form is submitted. Otherwise, focus is transferred to the next component in the form.
Specified by:
actionPerformed in interface ActionListener
Parameters:
evt - the ActionEvent.

createComponent

protected Component createComponent()
Create the component. This is basically a big switch statement based upon the tag type and html attributes of the associated element.
Overrides:
createComponent in interface ComponentView

getMaximumSpan

public float getMaximumSpan(int axis)
Determines the maximum span for this view along an axis. For certain components, the maximum and preferred span are the same. For others this will return the value returned by Component.getMaximumSize along the axis of interest.
Overrides:
getMaximumSpan in interface ComponentView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the span the view would like to be rendered into >= 0. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
Throws:
IllegalArgumentException - for an invalid axis

imageSubmit

protected void imageSubmit(String imageData)
This method is called to submit a form in response to a click on an image -- an <INPUT> form element of type "image".
Parameters:
imageData - the mouse click coordinates.

submitData

protected void submitData(String data)
This method is responsible for submitting the form data. A thread is forked to undertake the submission.