Java Doc for Alert.java in  » 6.0-JDK-Modules » j2me » javax » microedition » lcdui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » javax.microedition.lcdui 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.microedition.lcdui.Displayable
      javax.microedition.lcdui.Screen
         javax.microedition.lcdui.Alert

All known Subclasses:   com.sun.midp.main.HeadlessAlert,  com.sun.midp.lcdui.SystemAlert,
Alert
public class Alert extends Screen (Code)
An alert is a screen that shows data to the user and waits for a certain period of time before proceeding to the next Displayable. An alert can contain a text string and an image. The intended use of Alert is to inform the user about errors and other exceptional conditions.

The application can set the alert time to be infinity with setTimeout(Alert.FOREVER) in which case the Alert is considered to be modal and the implementation provide a feature that allows the user to "dismiss" the alert, whereupon the next Displayable is displayed as if the timeout had expired immediately.

If an application specifies an alert to be of a timed variety and gives it too much content such that it must scroll, then it automatically becomes a modal alert.

An alert may have an AlertType 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 Alert is presented to the user. See AlertType.playSound(javax.microedition.lcdui.Display) AlertType.playSound() .

An alert may contain an optional Image. The Image may be mutable or immutable. If the Image is mutable, the effect is as if a snapshot of its contents is taken at the time the Alert is constructed with this Image and when setImage is called with an Image. This snapshot is used whenever the contents of the Alert are to be displayed. Even if the application subsequently draws into the Image, the snapshot is not modified until the next call to setImage. The snapshot is not updated when the Alert becomes current or becomes visible on the display. (This is because the application does not have control over exactly when Displayables appear and disappear from the display.)

Activity Indicators

An alert may contain an optional Gauge object that is used as an activity or progress indicator. By default, an Alert has no activity indicator; one may be set with the Alert.setIndicator method. The Gauge object used for the activity indicator must conform to all of the following restrictions:

  • it must be non-interactive;
  • it must not be owned by another container (Alert or Form);
  • it must not have any Commands;
  • it must not have an ItemCommandListener;
  • it must not have a label (that is, its label must be null;
  • its preferred width and height must both be unlocked; and
  • its layout value must be LAYOUT_DEFAULT.

It is an error for the application to attempt to use a Gauge object that violates any of these restrictions. In addition, when the Gauge object is being used as the indicator within an Alert, the application is prevented from modifying any of these pieces of the Gauge's state.

Commands and Listeners

Like the other Displayable classes, an Alert can accept Commands, which can be delivered to a CommandListener set by the application. The Alert class adds some special behavior for Commands and listeners.

When it is created, an Alert implicitly has the special Command Alert.DISMISS_COMMAND present on it. If the application adds any other Commands to the Alert, DISMISS_COMMAND is implicitly removed. If the application removes all other Commands, DISMISS_COMMAND is implicitly restored. Attempts to add or remove DISMISS_COMMAND explicitly are ignored. Thus, there is always at least one Command present on an Alert.

If there are two or more Commands present on the Alert, it is automatically turned into a modal Alert, and the timeout value is always Alert.FOREVER . The Alert remains on the display until a Command is invoked. If the Alert has one Command (whether it is DISMISS_COMMAND or it is one provided by the application), the Alert may have the timed behavior as described above. When a timeout occurs, the effect is the same as if the user had invoked the Command explicitly.

When it is created, an Alert implicitly has a CommandListener called the default listener associated with it. This listener may be replaced by an application-provided listener through use of the Alert.setCommandListener method. If the application removes its listener by passing null to the setCommandListener method, the default listener is implicitly restored.

The Display.setCurrent(AlertDisplayable) method and the Display.setCurrent(Displayable) method (when called with an Alert) define special behavior for automatically advancing to another Displayable after the Alert is dismissed. This special behavior occurs only when the default listener is present on the Alert at the time it is dismissed or when a command is invoked. If the user invokes a Command and the default listener is present, the default listener ignores the Command and implements the automatic-advance behavior.

If the application has set its own CommandListener, the automatic-advance behavior is disabled. The listener code is responsible for advancing to another Displayable. When the application has provided a listener, Commands are invoked normally by passing them to the listener's commandAction method. The Command passed will be one of the Commands present on the Alert: either DISMISS_COMMAND or one of the application-provided Commands.

The application can restore the default listener by passing null to the setCommandListener method.

Note: An application may set a Ticker Ticker with Displayable.setTicker Displayable.setTicker on an Alert, however it may not be displayed due to implementation restrictions.


See Also:   AlertType
since:
   MIDP 1.0


Field Summary
final public static  CommandDISMISS_COMMAND
     A Command delivered to a listener to indicate that the Alert has been dismissed.
final public static  intFOREVER
     FOREVER indicates that an Alert is kept visible until the user dismisses it.
 AlertLFalertLF
    
 Imageimage
    
 Gaugeindicator
    
 DisplayablereturnScreen
    
 Stringtext
    
 inttime
    
 AlertTypetype
    
 CommandListeneruserCommandListener
    

Constructor Summary
public  Alert(String title)
     Constructs a new, empty Alert object with the given title.
public  Alert(String title, String alertText, Image alertImage, AlertType alertType)
     Constructs a new Alert object with the given title, content string and image, and alert type. The layout of the contents is implementation dependent. The timeout value of this new alert is the same value that is returned by getDefaultTimeout(). The Image provided may either be mutable or immutable. The handling and behavior of specific AlertTypes is described in AlertType .

Method Summary
public  voidaddCommand(Command cmd)
     Similar to Displayable.addCommand , however when the application first adds a command to an Alert, Alert.DISMISS_COMMAND is implicitly removed.
public  intgetDefaultTimeout()
     Gets the default time for showing an Alert.
public  ImagegetImage()
     Gets the Image used in the Alert.
public  GaugegetIndicator()
     Gets the activity indicator for this Alert.
 DisplayablegetReturnScreen()
     Get the screen that the display should return to when this Alert is dismissed.
public  StringgetString()
     Gets the text string used in the Alert.
public  intgetTimeout()
     Gets the time this Alert will be shown.
public  AlertTypegetType()
     Gets the type of the Alert.
 voidlDismiss()
     Dismisses this alert.
public  voidremoveCommand(Command cmd)
     Similar to Displayable.removeCommand , however when the application removes the last command from an Alert, Alert.DISMISS_COMMAND is implicitly added.
public  voidsetCommandListener(CommandListener l)
     The same as Displayable.setCommandListener but with the following additional semantics.
public  voidsetImage(Image img)
     Sets the Image used in the Alert. The Image may be mutable or immutable.
public  voidsetIndicator(Gauge indicator)
     Sets an activity indicator on this Alert.
 voidsetReturnScreen(Displayable d)
     Set the screen that the display should return to when this Alert is dismissed.
public  voidsetString(String str)
     Sets the text string used in the Alert.
public  voidsetTimeout(int time)
     Set the time for which the Alert is to be shown.
public  voidsetType(AlertType type)
     Sets the type of the Alert.
 voiduNotifyTimeout()
     LF notifies that the Alert is dismissed due to timeout, instead of user action.

Field Detail
DISMISS_COMMAND
final public static Command DISMISS_COMMAND(Code)
A Command delivered to a listener to indicate that the Alert has been dismissed. This Command is implicitly present an on Alert whenever there are no other Commands present. The field values of DISMISS_COMMAND are as follows:
  • label = "" (an empty string)
  • type = Command.OK
  • priority = 0

The label value visible to the application must be as specified above. However, the implementation may display DISMISS_COMMAND to the user using an implementation-specific label.

Attempting to add or remove DISMISS_COMMAND from an Alert has no effect. However, DISMISS_COMMAND is treated as an ordinary Command if it is used with other Displayable types.




FOREVER
final public static int FOREVER(Code)
FOREVER indicates that an Alert is kept visible until the user dismisses it. It is used as a value for the parameter to Alert.setTimeout(int) setTimeout() to indicate that the alert is modal. Instead of waiting for a specified period of time, a modal Alert will wait for the user to take some explicit action, such as pressing a button, before proceeding to the next Displayable.

Value -2 is assigned to FOREVER.




alertLF
AlertLF alertLF(Code)
The Alert look&feel object associated with this Alert



image
Image image(Code)
The image of this alert



indicator
Gauge indicator(Code)
The activity indicator for this alert



returnScreen
Displayable returnScreen(Code)
The screen which the display will return to when this Alert is completed



text
String text(Code)
The layout object for the alert text string



time
int time(Code)
The timeout value of this alert



type
AlertType type(Code)
The type of this alert



userCommandListener
CommandListener userCommandListener(Code)
The application's command listener




Constructor Detail
Alert
public Alert(String title)(Code)
Constructs a new, empty Alert object with the given title. If null is passed, the Alert will have no title. Calling this constructor is equivalent to calling
 Alert(title, null, null, null)
 

Parameters:
  title - the title string, or null
See Also:   Alert.Alert(String,String,Image,AlertType)



Alert
public Alert(String title, String alertText, Image alertImage, AlertType alertType)(Code)
Constructs a new Alert object with the given title, content string and image, and alert type. The layout of the contents is implementation dependent. The timeout value of this new alert is the same value that is returned by getDefaultTimeout(). The Image provided may either be mutable or immutable. The handling and behavior of specific AlertTypes is described in AlertType . null is allowed as the value of the alertType parameter and indicates that the Alert is not to have a specific alert type. DISMISS_COMMAND is the only Command present on the new Alert. The CommandListener associated with the new Alert is the default listener. Its behavior is described in more detail in the section Commands and Listeners.
Parameters:
  title - the title string, or null if there is no title
Parameters:
  alertText - the string contents, or null if there is no string
Parameters:
  alertImage - the image contents, or null if there is no image
Parameters:
  alertType - the type of the Alert, ornullif the Alert has nospecific type




Method Detail
addCommand
public void addCommand(Command cmd)(Code)
Similar to Displayable.addCommand , however when the application first adds a command to an Alert, Alert.DISMISS_COMMAND is implicitly removed. Calling this method with DISMISS_COMMAND as the parameter has no effect.
Parameters:
  cmd - the command to be added
throws:
  NullPointerException - if cmd is null



getDefaultTimeout
public int getDefaultTimeout()(Code)
Gets the default time for showing an Alert. This is either a positive value, which indicates a time in milliseconds, or the special value Alert.FOREVER FOREVER , which indicates that Alerts are modal by default. The value returned will vary across implementations and is presumably tailored to be suitable for each. default timeout in milliseconds, or FOREVER



getImage
public Image getImage()(Code)
Gets the Image used in the Alert. the Alert's image, or null if there is no image
See Also:   Alert.setImage



getIndicator
public Gauge getIndicator()(Code)
Gets the activity indicator for this Alert. a reference to this Alert's activity indicator,or null if there is none
See Also:   Alert.setIndicator



getReturnScreen
Displayable getReturnScreen()(Code)
Get the screen that the display should return to when this Alert is dismissed. The Displayable to display when this Alert is completed



getString
public String getString()(Code)
Gets the text string used in the Alert. the Alert's text string, or null if there is no text
See Also:   Alert.setString



getTimeout
public int getTimeout()(Code)
Gets the time this Alert will be shown. This is either a positive value, which indicates a time in milliseconds, or the special value FOREVER, which indicates that this Alert is modal. This value is not necessarily the same value that might have been set by the application in a call to Alert.setTimeout . In particular, if the Alert is made modal because its contents is large enough to scroll, the value returned by getTimeout will be FOREVER. timeout in milliseconds, or FOREVER
See Also:   Alert.setTimeout



getType
public AlertType getType()(Code)
Gets the type of the Alert. a reference to an instance of AlertType,or nullif the Alerthas no specific type
See Also:   Alert.setType



lDismiss
void lDismiss()(Code)
Dismisses this alert.



removeCommand
public void removeCommand(Command cmd)(Code)
Similar to Displayable.removeCommand , however when the application removes the last command from an Alert, Alert.DISMISS_COMMAND is implicitly added. Calling this method with DISMISS_COMMAND as the parameter has no effect.
Parameters:
  cmd - the command to be removed



setCommandListener
public void setCommandListener(CommandListener l)(Code)
The same as Displayable.setCommandListener but with the following additional semantics. If the listener parameter is null, the default listener is restored. See Commands and Listeners for the definition of the behavior of the default listener.
Parameters:
  l - the new listener, or null



setImage
public void setImage(Image img)(Code)
Sets the Image used in the Alert. The Image may be mutable or immutable. If img is null, specifies that this Alert has no image. If img is mutable, the effect is as if a snapshot is taken of img's contents immediately prior to the call to setImage. This snapshot is used whenever the contents of the Alert are to be displayed. If img is already the Image of this Alert, the effect is as if a new snapshot of img's contents is taken. Thus, after painting into a mutable image contained by an Alert, the application can call

 alert.setImage(alert.getImage());    

to refresh the Alert's snapshot of its Image.

If the Alert is visible on the display when its contents are updated through a call to setImage, the display will be updated with the new snapshot as soon as it is feasible for the implementation to do so.


Parameters:
  img - the Alert's image, or nullif there is no image
See Also:   Alert.getImage



setIndicator
public void setIndicator(Gauge indicator)(Code)
Sets an activity indicator on this Alert. The activity indicator is a Gauge object. It must be in a restricted state in order for it to be used as the activity indicator for an Alert. The restrictions are listed above. If the Gauge object violates any of these restrictions, IllegalArgumentException is thrown.

If indicator is null, this removes any activity indicator present on this Alert.


Parameters:
  indicator - the activity indicator for this Alert,or null if there is to be none
throws:
  IllegalArgumentException - if indicator does notmeet the restrictions for its use in an Alert
See Also:   Alert.getIndicator



setReturnScreen
void setReturnScreen(Displayable d)(Code)
Set the screen that the display should return to when this Alert is dismissed.
Parameters:
  d - The Displayable to display when this Alert is completed



setString
public void setString(String str)(Code)
Sets the text string used in the Alert.

If the Alert is visible on the display when its contents are updated through a call to setString, the display will be updated with the new contents as soon as it is feasible for the implementation to do so.


Parameters:
  str - the Alert's text string, or nullif there is no text
See Also:   Alert.getString



setTimeout
public void setTimeout(int time)(Code)
Set the time for which the Alert is to be shown. This must either be a positive time value in milliseconds, or the special value FOREVER.
Parameters:
  time - timeout in milliseconds, or FOREVER
throws:
  IllegalArgumentException - if time is not positive and isnot FOREVER
See Also:   Alert.getTimeout



setType
public void setType(AlertType type)(Code)
Sets the type of the Alert. The handling and behavior of specific AlertTypes is described in AlertType .
Parameters:
  type - an AlertType, or null if theAlert has nospecific type
See Also:   Alert.getType



uNotifyTimeout
void uNotifyTimeout()(Code)
LF notifies that the Alert is dismissed due to timeout, instead of user action. Commandlistener will be notified with the default Command.




Fields inherited from javax.microedition.lcdui.Displayable
Command commands(Code)(Java Doc)
DisplayableLF displayableLF(Code)(Java Doc)
boolean isInFullScreenMode(Code)(Java Doc)
boolean isRotated(Code)(Java Doc)
CommandListener listener(Code)(Java Doc)
int numCommands(Code)(Java Doc)
Ticker ticker(Code)(Java Doc)
String title(Code)(Java Doc)

Methods inherited from javax.microedition.lcdui.Displayable
public void addCommand(Command cmd)(Code)(Java Doc)
int addCommandImpl(Command cmd)(Code)(Java Doc)
public int getHeight()(Code)(Java Doc)
DisplayableLF getLF()(Code)(Java Doc)
public Ticker getTicker()(Code)(Java Doc)
public String getTitle()(Code)(Java Doc)
public int getWidth()(Code)(Java Doc)
public boolean isShown()(Code)(Java Doc)
void itemStateChanged(Item src)(Code)(Java Doc)
public void removeCommand(Command cmd)(Code)(Java Doc)
int removeCommandImpl(Command cmd)(Code)(Java Doc)
public void setCommandListener(CommandListener l)(Code)(Java Doc)
public void setTicker(Ticker ticker)(Code)(Java Doc)
public void setTitle(String s)(Code)(Java Doc)
protected void sizeChanged(int w, int h)(Code)(Java Doc)
void uCallItemStateChanged(Item src)(Code)(Java Doc)

Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.