我如何从LWUIT组件处置对话框 [英] How can i Dispose Dialog box From LWUIT Component

查看:99
本文介绍了我如何从LWUIT组件处置对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Midlet移动应用程序LWUIT开发一个项目.当我按数字键时,将打开一个对话框.当我按#,0,*键时,对话框应该关闭.
我正在使用Dialog.dispose()方法关闭对话框.但这是行不通的.下面是我的代码.谁能告诉我代码中的问题是什么?

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?

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.");
    }
 }

推荐答案

,您需要更新GUI.我不知道有什么可用的,但是redraw()repaint()refresh()是为此常用的命令.
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.


这篇关于我如何从LWUIT组件处置对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆