java left logo
java middle logo
java right logo
 

Home arrow Java ME Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4092
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to show an Alert containing an Image E-mail
User Rating: / 20
PoorBest 

This example shows an Alert containing an Image.


Image


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 Tips


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.