javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_04.java
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
child 84 0553e2305d00
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     1 /*
       
     2 * Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19  * import midp classes.
       
    20  */
       
    21 import javax.microedition.midlet.*;
       
    22 import javax.microedition.lcdui.*;
       
    23 
       
    24 /**
       
    25  *  This is the main class for the Midp_General_04 tests.
       
    26  */
       
    27 
       
    28 public class Midp_General_04 extends MIDlet implements CommandListener
       
    29 {
       
    30 
       
    31     private Alert alert;
       
    32     private Display display;
       
    33     private Gauge indicator;
       
    34     private Image image;
       
    35     private Command cmdScreen = new Command("Screen cmd", Command.SCREEN, 1);
       
    36     private Command cmdExit = new Command("Exit", Command.EXIT, 1);
       
    37 
       
    38     private String alertText = "This is a modal alert with very long text blah blah blah blah blah blah " +
       
    39                                "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
       
    40                                "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
       
    41                                "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
       
    42                                "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
       
    43                                "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " +
       
    44                                "blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
       
    45 
       
    46     public Midp_General_04()
       
    47     {
       
    48         alert = new Alert("Alert title", alertText, null, AlertType.INFO);
       
    49         alert.addCommand(cmdExit);
       
    50         alert.addCommand(cmdScreen);
       
    51         alert.setCommandListener(this);
       
    52         indicator = new Gauge(null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
       
    53         alert.setIndicator(indicator);
       
    54 
       
    55         try
       
    56         {
       
    57             image = Image.createImage("/small.png");
       
    58         }
       
    59         catch (java.io.IOException e)
       
    60         {
       
    61         }
       
    62         alert.setImage(image);
       
    63 
       
    64         display = Display.getDisplay(this);
       
    65     }
       
    66 
       
    67     /**
       
    68      * Signals the MIDlet to start and enter the Active state.
       
    69      */
       
    70     protected void startApp()
       
    71     {
       
    72         display.setCurrent(alert);
       
    73     }
       
    74 
       
    75     /**
       
    76      *  Signals the MIDlet to terminate and enter the Destroyed state.
       
    77      *
       
    78      */
       
    79     protected void destroyApp(boolean unconditional)
       
    80     {
       
    81     }
       
    82 
       
    83     /**
       
    84      *  Signals the MIDlet to stop and enter the Paused state.
       
    85      */
       
    86     protected void pauseApp()
       
    87     {
       
    88     }
       
    89 
       
    90     /**
       
    91      *  This method handles command invocations.
       
    92      *
       
    93      *@param  c  This is the command responsible for the event.
       
    94      *@param  s  Should be equal to this.
       
    95      */
       
    96     public void commandAction(Command c, Displayable s)
       
    97     {
       
    98         if (c == cmdExit)
       
    99         {
       
   100             destroyApp(false);
       
   101             notifyDestroyed();
       
   102         }
       
   103         else if (c == cmdScreen)
       
   104         {
       
   105             alert.setTitle("Command run");
       
   106         }
       
   107     }
       
   108 }