📄 alert.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 Alert
</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/Alert.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">
PREV CLASS
<A HREF="../../../javax/microedition/lcdui/AlertType.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="Alert.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 Alert</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.Alert</B>
</PRE>
<HR>
<DL>
<DT>public class <B>Alert</B><DT>extends <A HREF="../../../javax/microedition/lcdui/Screen.html">Screen</A></DL>
<P>
An alert is a screen that shows data to the user and waits for a certain period of time before proceeding to the next <code>Displayable</code>. An alert can contain a text string and an image. The intended use of <code>Alert</code> is to inform the user about errors and other exceptional conditions. <P>The application can set the alert time to be infinity with <code> setTimeout(Alert.FOREVER)</code> in which case the <code>Alert</code> is considered to be <em>modal</em> and the implementation provide a feature that allows the user to "dismiss" the alert, whereupon the next <code>Displayable</code> is displayed as if the timeout had expired immediately.</P> <P>If an application specifies an alert to be of a timed variety <em>and</em> gives it too much content such that it must scroll, then it automatically becomes a modal alert.</P> <P> An alert may have an <code>AlertType</code> associated with it to provide an indication of the nature of the alert. The implementation may use this type to play an appropriate sound when the <code>Alert</code> is presented to the user. See <A HREF="../../../javax/microedition/lcdui/AlertType.html#playSound(javax.microedition.lcdui.Display)"><CODE>AlertType.playSound()</CODE></A>.</P> <P>An alert may contain an optional <code>Image</code>. The <code>Image</code> may be mutable or immutable. If the <code>Image</code> is mutable, the effect is as if a snapshot of its contents is taken at the time the <code>Alert</code> is constructed with this <code>Image</code> and when <code>setImage</code> is called with an <code>Image</code>. This snapshot is used whenever the contents of the <code>Alert</code> are to be displayed. Even if the application subsequently draws into the <code>Image</code>, the snapshot is not modified until the next call to <code>setImage</code>. The snapshot is <em>not</em> updated when the <code>Alert</code> becomes current or becomes visible on the display. (This is because the application does not have control over exactly when <code>Displayables</code> appear and disappear from the display.)</P> <a name="indicator"></a> <h3>Activity Indicators</h3> <P>An alert may contain an optional <A HREF="../../../javax/microedition/lcdui/Gauge.html"><CODE>Gauge</CODE></A> object that is used as an activity or progress indicator. By default, an <code>Alert</code> has no activity indicator; one may be set with the <A HREF="../../../javax/microedition/lcdui/Alert.html#setIndicator(javax.microedition.lcdui.Gauge)"><CODE>setIndicator(javax.microedition.lcdui.Gauge)</CODE></A> method. The <code>Gauge</code> object used for the activity indicator must conform to all of the following restrictions:</P> <ul> <li>it must be non-interactive;</li> <li>it must not be owned by another container (<code>Alert</code> or <code>Form</code>);</li> <li>it must not have any <code>Commands</code>;</li> <li>it must not have an <code>ItemCommandListener</code>;</li> <li>it must not have a label (that is, its label must be <code>null</code>;</li> <li>its preferred width and height must both be unlocked; and</li> <li>its layout value must be <code>LAYOUT_DEFAULT</code>.</li> </ul> <P>It is an error for the application to attempt to use a <code>Gauge</code> object that violates any of these restrictions. In addition, when the <code>Gauge</code> object is being used as the indicator within an <code>Alert</code>, the application is prevented from modifying any of these pieces of the <code>Gauge's</code> state.</P> <a name="commands"></a> <h3>Commands and Listeners</h3> <P>Like the other <code>Displayable</code> classes, an <code>Alert</code> can accept <code>Commands</code>, which can be delivered to a <code>CommandListener</code> set by the application. The <code>Alert</code> class adds some special behavior for <code>Commands</code> and listeners.</P> <P>When it is created, an <code>Alert</code> implicitly has the special <code>Command</code> <A HREF="../../../javax/microedition/lcdui/Alert.html#DISMISS_COMMAND"><CODE>DISMISS_COMMAND</CODE></A> present on it. If the application adds any other <code>Commands</code> to the <code>Alert</code>, <code>DISMISS_COMMAND</code> is implicitly removed. If the application removes all other <code>Commands</code>, <code>DISMISS_COMMAND</code> is implicitly restored. Attempts to add or remove <code>DISMISS_COMMAND</code> explicitly are ignored. Thus, there is always at least one <code>Command</code> present on an <code>Alert</code>. </P> <P>If there are two or more <code>Commands</code> present on the <code>Alert</code>, it is automatically turned into a modal <code>Alert</code>, and the timeout value is always <A HREF="../../../javax/microedition/lcdui/Alert.html#FOREVER"><CODE>FOREVER</CODE></A>. The <code>Alert</code> remains on the display until a <code>Command</code> is invoked. If the Alert has one Command (whether it is DISMISS_COMMAND or it is one provided by the application), the <code>Alert</code> may have the timed behavior as described above. When a timeout occurs, the effect is the same as if the user had invoked the <code>Command</code> explicitly.</P> <P>When it is created, an <code>Alert</code> implicitly has a <code>CommandListener</code> called the <em>default listener</em> associated with it. This listener may be replaced by an application-provided listener through use of the <A HREF="../../../javax/microedition/lcdui/Alert.html#setCommandListener(javax.microedition.lcdui.CommandListener)"><CODE>setCommandListener(javax.microedition.lcdui.CommandListener)</CODE></A> method. If the application removes its listener by passing <code>null</code> to the <code>setCommandListener</code> method, the default listener is implicitly restored.</P> <P>The <A HREF="../../../javax/microedition/lcdui/Display.html#setCurrent(javax.microedition.lcdui.Alert, javax.microedition.lcdui.Displayable)"><CODE>Display.setCurrent(Alert, Displayable)</CODE></A> method and the <A HREF="../../../javax/microedition/lcdui/Display.html#setCurrent(javax.microedition.lcdui.Displayable)"><CODE>Display.setCurrent(Displayable)</CODE></A> method (when called with an <code>Alert</code>) define special behavior for automatically advancing to another <code>Displayable</code> after the <code>Alert</code> is dismissed. This special behavior occurs only when the default listener is present on the <code>Alert</code> at the time it is dismissed or when a command is invoked. If the user invokes a <code>Command</code> and the default listener is present, the default listener ignores the <code>Command</code> and implements the automatic-advance behavior.</P> <P>If the application has set its own <code>CommandListener</code>, the automatic-advance behavior is disabled. The listener code is responsible for advancing to another <code>Displayable</code>. When the application has provided a listener, <code>Commands</code> are invoked normally by passing them to the listener's <code>commandAction</code> method. The <code>Command</code> passed will be one of the <code>Commands</code> present on the <code>Alert</code>: either <code>DISMISS_COMMAND</code> or one of the application-provided <code>Commands</code>.</P> <P>The application can restore the default listener by passing <code>null</code> to the <code>setCommandListener</code> method.</P> <P> <strong>Note:</strong> An application may set a <A HREF="../../../javax/microedition/lcdui/Ticker.html"><CODE>Ticker</CODE></A> with <A HREF="../../../javax/microedition/lcdui/Displayable.html#setTicker(javax.microedition.lcdui.Ticker)"><CODE>Displayable.setTicker</CODE></A> on an <code>Alert</code>, however it may not be displayed due to implementation restrictions. </P>
<P>
<DL>
<DT><B>Since: </B><DD>MIDP 1.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/AlertType.html"><CODE>AlertType</CODE></A></DL>
<HR>
<P>
<!-- ======== INNER CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Field Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static <A HREF="../../../javax/microedition/lcdui/Command.html">Command</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Alert.html#DISMISS_COMMAND">DISMISS_COMMAND</A></B></CODE>
<BR>
A <code>Command</code> delivered to a listener to indicate that the <code>Alert</code> has been dismissed.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Alert.html#FOREVER">FOREVER</A></B></CODE>
<BR>
<code>FOREVER</code> indicates that an <code>Alert</code> is kept visible until the user dismisses it.</TD>
</TR>
</TABLE>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Alert.html#Alert(java.lang.String)">Alert</A></B>(<A HREF="../../../java/lang/String.html">String</A> title)</CODE>
<BR>
Constructs a new, empty <code>Alert</code> object with the given title.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../javax/microedition/lcdui/Alert.html#Alert(java.lang.String, java.lang.String, javax.microedition.lcdui.Image, javax.microedition.lcdui.AlertType)">Alert</A></B>(<A HREF="../../../java/lang/String.html">String</A> title, <A HREF="../../../java/lang/String.html">String</A> alertText, <A HREF="../../../javax/microedition/lcdui/Image.html">Image</A> alertImage, <A HREF="../../../javax/microedition/lcdui/AlertType.html">AlertType</A> alertType)</CODE>
<BR>
Constructs a new <code>Alert</code> object with the given title, content string and image, and alert type.</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -