如何在j2me中从另一个java程序显示父midlet

发布于 2024-12-20 16:57:30 字数 1946 浏览 3 评论 0原文

我正在开发一个 j2me 应用程序,其中有一个调用其他 java 程序的父 midlet。父 midlet 是包含 4 个元素的隐式列表。单击任何元素后,就会调用适当的 java 程序。一切工作正常,但我不明白如何在单击后退按钮时从 java 程序显示父 midlet。

请举例说明。 这是我的父 midlet 代码

package hello;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
public class Contacts extends MIDlet implements CommandListener,Runnable {
Display display=null;

private Form form=new Form("Contacts");
private List menu=new List("Contact Menu",Choice.IMPLICIT);
private Command exit = new Command("Exit", Command.EXIT, 2);
private Command ok=new Command("Ok",Command.SCREEN,1);
private Command back = new Command("Back", Command.BACK, 1);

private Alert alert;
public Contacts()
{
    display = Display.getDisplay(this);
  try{
      menu.append("Add Contact", Image.createImage("/contact_new.png"));
      menu.append("Delete Contact",Image.createImage("/delete-icon.png"));
      menu.append("Get Contact",Image.createImage("/document-edit.png"));
      menu.append("View Contacts",Image.createImage("/view.png"));
      menu.addCommand(ok);
      menu.addCommand(exit);
      menu.setCommandListener(this);

      }
     catch(IOException ie)
     {
             }
        }
    public void startApp() {
    display.setCurrent(menu);
        }

    public void pauseApp() {
        }

public void destroyApp(boolean unconditional) {
      }
public void commandAction(Command command, Displayable displayable) {
if (command == exit) {
  destroyApp(true);
  notifyDestroyed();
  return;
  } 
     switch (menu.getSelectedIndex ()) {
    case 0:
         new ac (this);//call to java program
               break;

    case 1:
         new dc (this);
        break;
    case 2:
        new gc(this);
        break;
   case 3:
         new vc(this);
           break;

    default:
        System.err.println ("Unexpected choice...");

        break;

    }


  }


        }

I am developing a j2me application where there is one parent midlet which calls other java programs. Parent midlet is of implicit list which contains 4 elements. On clicking any of the elements an appropriate java program is called. Everything is working fine, but i don't understand how to show parent midlet from java program on clicking of back button.

Please provide examples.
this is my parent midlet code

package hello;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
public class Contacts extends MIDlet implements CommandListener,Runnable {
Display display=null;

private Form form=new Form("Contacts");
private List menu=new List("Contact Menu",Choice.IMPLICIT);
private Command exit = new Command("Exit", Command.EXIT, 2);
private Command ok=new Command("Ok",Command.SCREEN,1);
private Command back = new Command("Back", Command.BACK, 1);

private Alert alert;
public Contacts()
{
    display = Display.getDisplay(this);
  try{
      menu.append("Add Contact", Image.createImage("/contact_new.png"));
      menu.append("Delete Contact",Image.createImage("/delete-icon.png"));
      menu.append("Get Contact",Image.createImage("/document-edit.png"));
      menu.append("View Contacts",Image.createImage("/view.png"));
      menu.addCommand(ok);
      menu.addCommand(exit);
      menu.setCommandListener(this);

      }
     catch(IOException ie)
     {
             }
        }
    public void startApp() {
    display.setCurrent(menu);
        }

    public void pauseApp() {
        }

public void destroyApp(boolean unconditional) {
      }
public void commandAction(Command command, Displayable displayable) {
if (command == exit) {
  destroyApp(true);
  notifyDestroyed();
  return;
  } 
     switch (menu.getSelectedIndex ()) {
    case 0:
         new ac (this);//call to java program
               break;

    case 1:
         new dc (this);
        break;
    case 2:
        new gc(this);
        break;
   case 3:
         new vc(this);
           break;

    default:
        System.err.println ("Unexpected choice...");

        break;

    }


  }


        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜夜流光相皎洁 2024-12-27 16:57:30

我不知道标准 J2ME 中有任何 API 可以在 MIDlet 之间进行交互。至少已经发布了。有一些诺基亚专用 API 可以执行此类操作。

I don't know any API in standard J2ME to interact between MIDlets. At least that is already released. There is some Nokia private API to do some such kind of operations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文