Click here to Skip to main content
15,923,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing one project using LWUIT, Midlet mobile Application. when I press number keys a dialog box will open. when i press the keys #,0,* Dialog should be close.
I am using Dialog.dispose() method to close dialog. But it is not working. Below is my Code. Can anyone tell me what is the problem in my code?

Java
import com.sun.lwuit.Dialog;
import com.sun.lwuit.Dialog.*;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.plaf.Border.*;
public class javaForm extends Component implements ActionListener
 {
    Dialog d;
    javaForm()
     {
       d=new Dialog(); 
     }

public void keyPressed(int key)
  {
    System.out.println("Key pressed :"+key);

      switch(key)
       {
               case 48:
                       d.show();
                       break;
               case 52:
                       d.dispose();
                       break;
               default:
                       break;
                    } 
      }
 public void actionPerformed(ActionEvent ae) 
   {
       throw new UnsupportedOperationException("Not supported yet.");
    }
 }
Posted

1 solution

you need to update the GUI. I don't know what is available for you but redraw() , repaint() and refresh() are common used commands for this.
 
Share this answer
 
Comments
Shankar nehrumaharajan 24-Jan-12 2:18am    
@TorstenH. Am not drawing anything here.a dialog is a class like buttons,textbox..etc
TorstenH. 24-Jan-12 5:03am    
na - really?
Serious. There might be a difference between what is displayed and what is in the memory. Have you tried updating the GUI?
Shankar nehrumaharajan 24-Jan-12 5:11am    
Updating GUI Means What ?
Shankar nehrumaharajan 24-Jan-12 6:59am    
Can you Post Some Alternate Code for this please!
TorstenH. 24-Jan-12 7:40am    
switch condition: add a "this.repaint();" after the "d.dispose;".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900