📄 form.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Wed Sep 24 14:57:49 PDT 2003 -->
<TITLE>
MID Profile: Class Form
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Form.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<strong>MID Profile</strong></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/microedition/lcdui/Font.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/lcdui/Gauge.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="Form.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.microedition.lcdui</FONT>
<BR>
Class Form</H2>
<PRE>
<A HREF="../../../java/lang/Object.html">java.lang.Object</A>
|
+--<A HREF="../../../javax/microedition/lcdui/Displayable.html">javax.microedition.lcdui.Displayable</A>
|
+--<A HREF="../../../javax/microedition/lcdui/Screen.html">javax.microedition.lcdui.Screen</A>
|
+--<B>javax.microedition.lcdui.Form</B>
</PRE>
<HR>
<DL>
<DT>public class <B>Form</B><DT>extends <A HREF="../../../javax/microedition/lcdui/Screen.html">Screen</A></DL>
<P>
A <code>Form</code> is a <code>Screen</code> that contains an arbitrary mixture of items: images, read-only text fields, editable text fields, editable date fields, gauges, choice groups, and custom items. In general, any subclass of the <A HREF="../../../javax/microedition/lcdui/Item.html"><CODE>Item</CODE></A> class may be contained within a form. The implementation handles layout, traversal, and scrolling. The entire contents of the <code>Form</code> scrolls together. <h2>Item Management</h2> <p> The items contained within a <code>Form</code> may be edited using append, delete, insert, and set methods. <code>Items</code> within a <code>Form</code> are referred to by their indexes, which are consecutive integers in the range from zero to <code>size()-1</code>, with zero referring to the first item and <code>size()-1</code> to the last item. </p> <p> An item may be placed within at most one <code>Form</code>. If the application attempts to place an item into a <code>Form</code>, and the item is already owned by this or another <code>Form</code>, an <code>IllegalStateException</code> is thrown. The application must remove the item from its currently containing <code>Form</code> before inserting it into the new <code>Form</code>. </p> <p> If the <code>Form</code> is visible on the display when changes to its contents are requested by the application, updates to the display take place as soon as it is feasible for the implementation to do so. Applications need not take any special action to refresh a <code>Form's</code> display after its contents have been modified. </p> <a name="layout"></a> <h2>Layout</h2> <p>Layout policy in <code>Form</code> is organized around rows. Rows are typically related to the width of the screen, respective of margins, scroll bars, and such. All rows in a particular <code>Form</code> will have the same width. Rows do not vary in width based on the <code>Items</code> contained within the <code>Form</code>, although they may all change width in certain circumstances, such as when a scroll bar needs to be added or removed. <code>Forms</code> generally do not scroll horizontally.</p> <p><code>Forms</code> grow vertically and scroll vertically as necessary. The height of a <code>Form</code> varies depending upon the number of rows and the height of each row. The height of each row is determined by the items that are positioned on that row. Rows need not all have the same height. Implementations may also vary row heights to provide proper padding or vertical alignment of <code>Item</code> labels.</p> <p>An implementation may choose to lay out <code>Items</code> in a left-to-right or right-to-left direction depending upon the language conventions in use. The same choice of layout direction must apply to all rows within a particular <code>Form</code>.</p> <p>Prior to the start of the layout algorithm, the <code>Form</code> is considered to have one empty row at the top. The layout algorithm considers each Item in turn, starting at <code>Item</code> zero and proceeding in order through each <code>Item</code> until the last <code>Item</code> in the <code>Form</code> has been processed. If the layout direction (as described above) is left-to-right, the beginning of the row is the left edge of the <code>Form</code>. If the layout direction is right-to-left, the beginning of the row is the right edge of the <code>Form</code>. <code>Items</code> are laid out at the beginning of each row, proceeding across each row in the chosen layout direction, packing as many <code>Items</code> onto each row as will fit, unless a condition occurs that causes the packing of a row to be terminated early. A new row is then added, and <code>Items</code> are packed onto it as described above. <code>Items</code> are packed onto rows, and new rows are added below existing rows as necessary until all <code>Items</code> have been processed by the layout algorithm.</p> <p>The layout algorithm has a concept of a <em>current alignment</em>. It can have the value <code>LAYOUT_LEFT</code>, <code>LAYOUT_CENTER</code>, or <code>LAYOUT_RIGHT</code>. The value of the current alignment at the start of the layout algorithm depends upon the layout direction in effect for this <code>Form</code>. If the layout direction is left-to-right, the initial alignment value must be <code>LAYOUT_LEFT</code>. If the layout direction is right-to-left, the initial alignment value must be <code>LAYOUT_RIGHT</code>. The current alignment changes when the layout algorithm encounters an <code>Item</code> that has one of the layout directives <code>LAYOUT_LEFT</code>, <code>LAYOUT_CENTER</code>, or <code>LAYOUT_RIGHT</code>. If none of these directives is present on an <code>Item</code>, the current layout directive does not change. This rule has the effect of grouping the contents of the <code>Form</code> into sequences of consecutive <code>Items</code> sharing an alignment value. The alignment value of each <code>Item</code> is maintained internally to the <code>Form</code> and does not affect the <code>Items'</code> layout value as reported by the <A HREF="../../../javax/microedition/lcdui/Item.html#getLayout()"><CODE>Item.getLayout</CODE></A> method.</p> <p>The layout algorithm generally attempts to place an item on the same row as the previous item, unless certain conditions occur that cause a "row break." When there is a row break, the current item will be placed at the beginning of a new row instead of being placed after the previous item, even if there is room.</p> <p>A row break occurs before an item if any of the following conditions occurs:</p> <ul> <li>the previous item has a row break after it;</li> <li>it has the <code>LAYOUT_NEWLINE_BEFORE</code> directive; or</li> <li>it is a <code>StringItem</code> whose contents starts with "\n";</li> <li>it is a <code>ChoiceGroup</code>, <code>DateField</code>, <code>Gauge</code>, or a <code>TextField</code>, and the <code>LAYOUT_2</code> directive is not set; or</li> <li>this <code>Item</code> has a <code>LAYOUT_LEFT</code>, <code>LAYOUT_CENTER</code>, or <code>LAYOUT_RIGHT</code> directive that differs from the <code>Form's</code> current alignment.</li> </ul> <p>A row break occurs after an item if any of the following conditions occurs:</p> <ul> <li>it is a <code>StringItem</code> whose contents ends with "\n"; or</li> <li>it has the <code>LAYOUT_NEWLINE_AFTER</code> directive; or</li> <li>it is a <code>ChoiceGroup</code>, <code>DateField</code>, <code>Gauge</code>, or a <code>TextField</code>, and the <code>LAYOUT_2</code> directive is not set.</li> </ul> <p>The presence of the <code>LAYOUT_NEWLINE_BEFORE</code> or <code>LAYOUT_NEWLINE_AFTER</code> directive does not cause an additional row break if there is one already present. For example, if a <code>LAYOUT_NEWLINE_BEFORE</code> directive appears on a <code>StringItem</code> whose contents starts with "\n", there is only a single row break. A similar rule applies with a trailing "\n" and <code>LAYOUT_NEWLINE_AFTER</code>. Also, there is only a single row break if an item has the <code>LAYOUT_NEWLINE_AFTER</code> directive and the next item has the <code>LAYOUT_NEWLINE_BEFORE</code> directive. However, the presence of consecutive "\n" characters, either within a single <code>StringItem</code> or in adjacent <code>StringItems</code>, will cause as many row breaks as there are "\n" characters. This will cause empty rows to be present. The height of an empty row is determined by the prevailing font height of the <code>StringItem</code> within which the "\n" that ends the row occurs.</p> <p>Implementations may provide additional conditions under which a row
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -