📄 customitem.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 CustomItem
</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/CustomItem.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/Command.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/lcdui/DateField.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="CustomItem.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <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 CustomItem</H2>
<PRE>
<A HREF="../../../java/lang/Object.html">java.lang.Object</A>
|
+--<A HREF="../../../javax/microedition/lcdui/Item.html">javax.microedition.lcdui.Item</A>
|
+--<B>javax.microedition.lcdui.CustomItem</B>
</PRE>
<HR>
<DL>
<DT>public abstract class <B>CustomItem</B><DT>extends <A HREF="../../../javax/microedition/lcdui/Item.html">Item</A></DL>
<P>
A CustomItem is customizable by subclassing to introduce new visual and interactive elements into <code>Forms</code>. Subclasses are responsible for their visual appearance including sizing and rendering and choice of colors, fonts and graphics. Subclasses are responsible for the user interaction mode by responding to events generated by keys, pointer actions, and traversal actions. Finally, subclasses are responsible for calling <A HREF="../../../javax/microedition/lcdui/Item.html#notifyStateChanged()"><CODE>Item.notifyStateChanged()</CODE></A> to trigger notification of listeners that the <code>CustomItem's</code> value has changed. <p>Like other <code>Items</code>, <code>CustomItems</code> have the concept of <em>minimum</em> and <em>preferred</em> sizes. These pertain to the total area of the <code>Item</code>, which includes space for the content, label, borders, etc. See <a href="Item.html#sizes">Item Sizes</a> for a full discussion of the areas and sizes of <code>Items</code>.</p> <p><code>CustomItem</code> subclasses also have the concept of the <em>content</em> size, which is the size of only the content area of the <code>CustomItem</code>. The content area is a rectangular area inside the total area occupied by the <code>CustomItem</code>. The content area is the area within which the <code>CustomItem</code> subclass paints and receives input events. It does not include space consumed by labels and borders. The implementation is responsible for laying out, painting, and handling input events within the area of the <code>Item</code> that is outside the content area.</p> <p>All coordinates passed between the implementation and the <code>CustomItem</code> subclass are relative to the item's content area, with the upper-left corner of this area being located at <code>(0,0)</code>. Size information passed between the implementation and the <code>CustomItem</code> subclass with the <A HREF="../../../javax/microedition/lcdui/CustomItem.html#getMinContentHeight()"><CODE>getMinContentHeight</CODE></A>, <A HREF="../../../javax/microedition/lcdui/CustomItem.html#getMinContentWidth()"><CODE>getMinContentWidth</CODE></A>, <A HREF="../../../javax/microedition/lcdui/CustomItem.html#getPrefContentHeight(int)"><CODE>getPrefContentHeight</CODE></A>, <A HREF="../../../javax/microedition/lcdui/CustomItem.html#getPrefContentWidth(int)"><CODE>getPrefContentWidth</CODE></A>, and <A HREF="../../../javax/microedition/lcdui/CustomItem.html#sizeChanged(int, int)"><CODE>sizeChanged</CODE></A> methods all refer to the size of the content area. The implementation is responsible for computing and maintaining the difference between the size of the content area and the size of the total area of the <code>Item</code> as reported by the Item size methods <A HREF="../../../javax/microedition/lcdui/Item.html#getMinimumHeight()"><CODE>Item.getMinimumHeight</CODE></A>, <A HREF="../../../javax/microedition/lcdui/Item.html#getMinimumWidth()"><CODE>Item.getMinimumWidth</CODE></A>, <A HREF="../../../javax/microedition/lcdui/Item.html#getPreferredHeight()"><CODE>Item.getPreferredHeight</CODE></A>, and <A HREF="../../../javax/microedition/lcdui/Item.html#getPreferredWidth()"><CODE>Item.getPreferredWidth</CODE></A>.</p> <p>The implementation may disregard sizing information returned from a <code>CustomItem</code> if it exceeds limits imposed by the implementation's user interface policy. In this case, the implementation must always report the actual size granted to the <code>CustomItem</code> via the <A HREF="../../../javax/microedition/lcdui/CustomItem.html#sizeChanged(int, int)"><CODE>sizeChanged</CODE></A> and the <A HREF="../../../javax/microedition/lcdui/CustomItem.html#paint(javax.microedition.lcdui.Graphics, int, int)"><CODE>paint</CODE></A> methods. For example, this situation may occur if the implementation prohibits an <code>Item</code> from becoming wider than the screen. If the <code>CustomItem</code> subclass code returns a value from <code>getMinContentWidth</code> that would result in the <code>CustomItem</code> being wider than the screen, the implementation may assign a width smaller than the minimum width returned by <code>getMinContentWidth</code>.</p> <p>The implementation is allowed to call the <code>CustomItem's</code> content size methods <A HREF="../../../javax/microedition/lcdui/CustomItem.html#getMinContentHeight()"><CODE>getMinContentHeight</CODE></A>, <A HREF="../../../javax/microedition/lcdui/CustomItem.html#getMinContentWidth()"><CODE>getMinContentWidth</CODE></A>, <A HREF="../../../javax/microedition/lcdui/CustomItem.html#getPrefContentHeight(int)"><CODE>getPrefContentHeight</CODE></A>, and <A HREF="../../../javax/microedition/lcdui/CustomItem.html#getPrefContentWidth(int)"><CODE>getPrefContentWidth</CODE></A>, in any order with respect to other <code>CustomItem</code> methods. For all of these methods, the <code>CustomItem</code> subclass code must return values that are consistent with the current contents of the <code>CustomItem</code>. If the contents changes, it is not sufficient for the <code>CustomItem</code> subclass code simply to begin returning different values from the content size methods. Instead, the subclass code must call the <A HREF="../../../javax/microedition/lcdui/CustomItem.html#invalidate()"><CODE>invalidate</CODE></A> method whenever its contents changes. This indicates to the implementation that it may need to perform its layout computation, which will call the content size methods to get new values based on the <code>CustomItem's</code> new contents.</p> <a name="interaction"></a> <h2>Interaction Modes</h2> <p>The <code>CustomItem</code> class is intended to allow edit-in-place on many items, but it does not allow every conceivable interaction. Desire for flexibility has been balanced against a requirement that these APIs be simple enough to master easily, along with a need to allow for platform-specific variations in look-and-feel, all without sacrificing interoperability.</p> <p>The general idea is that there are multiple interaction "modes" and that the <code>Form</code> implementation can convey which ones it supports. The <code>CustomItem</code> can then choose to support one or more interaction modes. There is no requirement for a <code>CustomItem</code> to implement all combinations of all interaction modes. Typically, a <code>CustomItem</code> will implement an approach (such as the separate editing screen technique discussed below) that works on all platforms, in addition to a highly interactive approach that relies on a particular interaction mode. At run time, the <code>CustomItem</code> code can query the system to determine whether this interaction mode is supported. If it is, the <code>CustomItem</code> can use it; otherwise, it will fall back to the approach that works on all platforms. </p> <p><code>CustomItem</code> can always use item commands to invoke a separate editing screen, although components with a small number of discrete states could simply respond by changing the state and then causing an <code>notifyStateChanged</code> notification. A technique for using a separate editing screen would be to load the value into another <code>Displayable</code> object (such as a List) and then to call <A HREF="../../../javax/microedition/lcdui/Display.html#setCurrent(javax.microedition.lcdui.Displayable)"><CODE>Display.setCurrent(Displayable)</CODE></A> on it. When the user issues a command (such as "OK") to indicate that editing of this value is complete, the listener can retrieve the value from that <code>Displayable</code> object and then call <A HREF="../../../javax/microedition/lcdui/Display.html#setCurrentItem(javax.microedition.lcdui.Item)"><CODE>Display.setCurrentItem(Item)</CODE></A> to return to this item.</p> <a name="keypad"></a> <h2>Keypad Input</h2> <p>The implementation may optionally support delivery of keypad events to the <code>CustomItem</code>. The implementation indicates the level of support by setting the <code>KEY_PRESS</code>, <code>KEY_RELEASE</code>, and <code>KEY_REPEAT</code> bits in the value returned by <code>getInteractionModes</code>. Events corresponding to these bits are delivered through calls to the <code>keyPressed()</code>, <code>keyReleased()</code>, and <code>keyRepeated()</code> methods, respectively. If an implementation supports <code>KEY_RELEASE</code> events, it must also support <code>KEY_PRESS</code> events. If an implementation supports <code>KEY_REPEAT</code> events, it must also support <code>KEY_PRESS</code> and <code>KEY_RELEASE</code> events. If supported, <code>KEY_RELEASE</code> events will generally occur after a corresponding <code>KEY_PRESS</code> event is received, and <code>KEY_REPEAT</code> events will generally occur between <code>KEY_PRESS</code> and <code>KEY_RELEASE</code> events. However, it is possible for the <code>CustomItem</code> to receive <code>KEY_RELEASE</code> or <code>KEY_REPEAT</code> events without a corresponding <code>KEY_PRESS</code> if a key is down when the <code>CustomItem</code> becomes visible.</p> <p>Key event methods are passed the <code>keyCode</code> indicating the key on which the event occurred. Implementations must provide means for the user to generate events with key codes <code>Canvas.KEY_NUM0</code> through <code>Canvas.KEY_NUM9</code>, <code>Canvas.KEY_STAR</code>, and <code>Canvas.KEY_POUND</code>. Implementations may also deliver key events for other keys, include device-specific keys. The set of keys available to a <code>CustomItem</code> may differ depending upon whether commands have been added to it.</p> <p>The application may map key codes to game actions through use of the <code>getGameAction</code> method. If the implementation supports key events on <code>CustomItems</code>, the implementation must provide a sufficient set of key codes and a mapping to game actions such that all game actions are available to <code>CustomItems</code>.</p> <p>The set of keys and the key events available to a <code>CustomItem</code> may differ from what is available on a <code>Canvas</code>. In particular, on a system that
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -