473,416 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Why I am not getting an alert dialog box?

108 100+
This is the script I modified.What I wanted here is as soon as the getDisplay() method is invocked,to get an alert box so I instantiated the alert class and implemented some codes fr this..But when I am running my script, my emulaor run as expected except that I don't get my alert box...

Why I am nt getting this alert box inspite of instantiating it?

Expand|Select|Wrap|Line Numbers
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package hello;
  7.  
  8. import javax.microedition.midlet.*;
  9. import javax.microedition.lcdui.*;
  10.  
  11. /**
  12.  * @author vimal
  13.  */
  14. public class HelloMIDlet extends MIDlet implements CommandListener {
  15.  
  16.     private boolean midletPaused = false;
  17.  
  18.     //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">                      
  19.     private Command exitCommand;
  20.     private Form form;
  21.     private StringItem stringItem;
  22.     //</editor-fold>                    
  23.  
  24.     /**
  25.      * The HelloMIDlet constructor.
  26.      */
  27.     public HelloMIDlet() {
  28.     }
  29.  
  30.     //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">                       
  31.     //</editor-fold>                     
  32.  
  33.     //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">                                           
  34.     /**
  35.      * Initilizes the application.
  36.      * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
  37.      */
  38.     private void initialize() {                                         
  39.         // write pre-initialize user code here
  40.  
  41.         // write post-initialize user code here
  42.     }                            
  43.     //</editor-fold>                          
  44.  
  45.     //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">                                        
  46.     /**
  47.      * Performs an action assigned to the Mobile Device - MIDlet Started point.
  48.      */
  49.     public void startMIDlet() {                                      
  50.         // write pre-action user code here
  51.         switchDisplayable(null, getForm());                                        
  52.         // write post-action user code here
  53.     }                             
  54.     //</editor-fold>                           
  55.  
  56.     //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">                                         
  57.     /**
  58.      * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
  59.      */
  60.     public void resumeMIDlet() {                                       
  61.         // write pre-action user code here
  62.  
  63.         // write post-action user code here
  64.     }                              
  65.     //</editor-fold>                            
  66.  
  67.     //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">                                              
  68.     /**
  69.      * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
  70.      * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
  71.      * @param nextDisplayable the Displayable to be set
  72.      */
  73.     public void switchDisplayable(Alert alert, Displayable nextDisplayable) {                                            
  74.         // write pre-switch user code here
  75.         Display display = getDisplay();                                               
  76.         if (alert == null) {
  77.             display.setCurrent(nextDisplayable);
  78.         } else {
  79.             display.setCurrent(alert, nextDisplayable);
  80.         }                                             
  81.         // write post-switch user code here
  82.     }                                   
  83.     //</editor-fold>                                 
  84.  
  85.     //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">                                                 
  86.     /**
  87.      * Called by a system to indicated that a command has been invoked on a particular displayable.
  88.      * @param command the Command that was invoked
  89.      * @param displayable the Displayable where the command was invoked
  90.      */
  91.     public void commandAction(Command command, Displayable displayable) {                                               
  92.         // write pre-action user code here
  93.         if (displayable == form) {                                           
  94.             if (command == exitCommand) {                                         
  95.                 // write pre-action user code here
  96.                 exitMIDlet();                                           
  97.                 // write post-action user code here
  98.             }                                                  
  99.         }                                                
  100.         // write post-action user code here
  101.     }                               
  102.     //</editor-fold>                             
  103.  
  104.     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">                                   
  105.     /**
  106.      * Returns an initiliazed instance of exitCommand component.
  107.      * @return the initialized component instance
  108.      */
  109.     public Command getExitCommand() {
  110.         if (exitCommand == null) {                                 
  111.             // write pre-init user code here
  112.             exitCommand = new Command("Exit", Command.EXIT, 0);                                   
  113.             // write post-init user code here
  114.         }                         
  115.         return exitCommand;
  116.     }
  117.     //</editor-fold>                       
  118.  
  119.     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">                                   
  120.     /**
  121.      * Returns an initiliazed instance of form component.
  122.      * @return the initialized component instance
  123.      */
  124.     public Form getForm() {
  125.         if (form == null) {                                 
  126.             // write pre-init user code here
  127.             form = new Form("Welcome", new Item[] { getStringItem() });                                    
  128.             form.addCommand(getExitCommand());
  129.             form.setCommandListener(this);                                  
  130.             // write post-init user code here
  131.         }                         
  132.         return form;
  133.     }
  134.     //</editor-fold>                       
  135.  
  136.     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem ">                                   
  137.     /**
  138.      * Returns an initiliazed instance of stringItem component.
  139.      * @return the initialized component instance
  140.      */
  141.     public StringItem getStringItem() {
  142.         if (stringItem == null) {                                 
  143.             // write pre-init user code here
  144.             stringItem = new StringItem("Hello", "Hello, World!");                                   
  145.             // write post-init user code here
  146.         }                         
  147.         return stringItem;
  148.     }
  149.     //</editor-fold>                       
  150.  
  151.     /**
  152.      * Returns a display instance.
  153.      * @return the display instance.
  154.      */
  155.     public Display getDisplay () {
  156.         System.out.println("Testing display ......");
  157.           System.out.println("");    System.out.println("");
  158.           System.out.println(".................Testing choice  ......");
  159.            System.out.println(Choice.EXCLUSIVE);
  160.             System.out.println(Choice. IMPLICIT );
  161.             System.out.println(Alert.FOREVER );
  162.             Alert al=new Alert("Testing alert");
  163.             System.out.println("");
  164.             System.out.println(al.getTimeout());
  165.             System.out.println(al.getString());
  166.             al.setString("This is a test alert");
  167.  
  168.  
  169.  
  170.  
  171.  
  172.         return Display.getDisplay(this);
  173.     }
  174.  
  175.     /**
  176.      * Exits MIDlet.
  177.      */
  178.     public void exitMIDlet() {
  179.         switchDisplayable (null, null);
  180.         destroyApp(true);
  181.         notifyDestroyed();
  182.     }
  183.  
  184.     /**
  185.      * Called when MIDlet is started.
  186.      * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
  187.      */
  188.     public void startApp() {
  189.         if (midletPaused) {
  190.             resumeMIDlet ();
  191.         } else {
  192.             initialize ();
  193.             startMIDlet ();
  194.         }
  195.         midletPaused = false;
  196.     }
  197.  
  198.     /**
  199.      * Called when MIDlet is paused.
  200.      */
  201.     public void pauseApp() {
  202.         midletPaused = true;
  203.     }
  204.  
  205.     /**
  206.      * Called to signal the MIDlet to terminate.
  207.      * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
  208.      */
  209.     public void destroyApp(boolean unconditional) {
  210.     }
  211.  
  212. }
  213.  

Thanks in adv
With regards
Jun 15 '10 #1
0 1265

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Steve | last post by:
I'm working in PHP, but am also using JavaScript, so perhaps there is a better way to do this using more PHP code...... I setup a search screen for my database, the user enters data and submits...
7
by: Andy Fish | last post by:
Hi, now I know what the alert() function does, but can anyone tell me where I can find the specification or standards for functions like alert() and confirm(). They don't seem to be part of...
2
by: Little Pete | last post by:
I use a simple .js script to shuffle files on my computer to which I'd like to add alert and confirmation boxes. Unfortunately I haven't been able to figure out what object I need to create that...
0
by: HaroldR | last post by:
I am programming a client side application that runs as a scheduled task. The program navigates to a web site and extracts information from a web page. However, the web server that generates the...
1
by: Yatharth | last post by:
Its a Web application. I am developing an application in which my page is refreshing continuosly.In that there is a textbox which is filled from the database ,and changed when i changed the ...
2
by: Kenneth | last post by:
Hi, In a document I have three lines that detects and redirects to another page is a session variable is 0 If Session("Customer_ID")=0 Then Response.Redirect("myPage.aspx") End If What I...
4
by: Robert Zurer | last post by:
When I click a Button server control I want two things to happen. The server returns a string array of error messages. A Javascript alert appears showing the errors. I can do this using the...
5
by: S.Vidya | last post by:
when accessing the URL using Https,the security alert box pop up everytime. how to block that security alert box showing 1.Certificate issued by a company you have not choosen to trust.view the...
6
by: BrianDH | last post by:
Hi We have a situation where our internal customer are required to respond to an alert (a company $$ issue) within a custom VB windows application. However, what we find is when they are busy...
3
by: Jamiil | last post by:
In my webpage there are acronyms that need explanation, for that I would like to display tip bubbles if possible, but I have not found any information regarding this programming feature in the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.