An example MIDlet with simple Alert UI component containing an Image. : Alert « J2ME « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
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 » J2ME » AlertScreenshots 
An example MIDlet with simple Alert UI component containing an Image.
An example MIDlet with simple Alert UI component containing an Image.


import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * An example MIDlet with simple "Alert" UI component containing an Image.
 */
public class AlertImage extends MIDlet
{

    private Display display;    // The display for this MIDlet
   private Alert myAlert = null;

    public AlertImage() {
    }

    /**
     * Call showAlert
     */
    public void startApp() {

       display = Display.getDisplay(this);
     TextBox t = new TextBox("Hello MIDlet""Hello J2MECamp!"2560);
     display.setCurrent(t);
     System.out.println"Gonna create Alert.." );
     createAlert();
   }



   /**
   * Puts up an Alert with an Image
   */
   private void createAlert() 
    {
     myAlert = new Alert("MIDlet Alert");
     String[] alertString = " Alert String" };
     myAlert.setTimeout(Alert.FOREVER);
   
       // Add an image to Alert
       if (display.numColors() 2
       {
          String icon = (display.isColor()) ?"/JavaPowered-8.png" "/JavaPowered-2.png";
           try
           {
              Image image = Image.createImageicon );
              if (image != null)
              {
                  myAlert.setImage(image);
                  System.out.println"Image created and added to alert.. " );
              }
              else
              {
                 System.out.println"No Image created... " );
              }
              // Add string to Alert
              for int i = 0; i < alertString.length; i++ ) {
                 myAlert.setStringalertString[i] );
              }
              
              if myAlert != null ) {
                display.setCurrentmyAlert );
              }
           }
           catchException e )
           {
              System.out.println"Exception in CreateImage() " );
           }
     }
    }
     

    /**
     * Pause is a no-op since there are no background activities or
     * record stores that need to be closed.
     */
    public void pauseApp() {
    }

    /**
     * Destroy must cleanup everything not handled by the garbage collector.
     * In this case there is nothing to cleanup.
     */
    public void destroyApp(boolean unconditional) {
    }

}



           
       
Related examples in the same category
1. High-Level Display Screens : AlertHigh-Level Display Screens : Alert
2. Animated TimerAnimated Timer
3. Two AlertsTwo Alerts
4. Login MidletLogin Midlet
5. Multi Alert
6. Modal AlertModal Alert
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.