File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes help me help me help me Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Reply Bookmark "help me help me help me" Watch "help me help me help me" New topic
Author

help me help me help me

nikunj anand
Greenhorn

Joined: Apr 06, 2007
Posts: 13
hello freinds.
please help me to solve my error.

first look at the below two programs.

My problem is when i have select list "Meditation " from first program i want to display second program form on midlet.

but when i run it, it throws some exception.

that is written at the end of second program.
so help me to solve program.

i have also select my security level to untrusted.

how can i display my second program form on selecting "meditation" list from frist program.

////////////////////////////first program
package Home;

import Meditation.MeditationMidlet;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
*
* @author krupa
* @version
*/
public class HomeMidlet extends MIDlet implements CommandListener
{
private Display display;
private List list;

private Ticker ticker;
private Command cmd_exit;
private Command cmd_ok;

public HomeMidlet()
{
display=Display.getDisplay(this);


ticker = new Ticker("WELCOME TO SWAMINARAYAN COMMUNITY PORTAL ");
list= new List("Services",List.IMPLICIT);
cmd_exit = new Command("Exit",Command.EXIT,2);
cmd_ok = new Command("Ok",Command.OK,1);

list.setTicker(ticker);
list.append("Downloads",null);
list.append("Profile",null);
list.append("Daily Murtidarshan",null);
list.append("Meditation",null);
list.append("Mahamantra Counter",null);
list.append("Quiz",null);
list.addCommand(cmd_exit);
list.addCommand(cmd_ok);
list.setCommandListener(this);

}

public void startApp() {
display.setCurrent(list);

}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
public void commandAction(Command cmd,Displayable dis)
{
if(cmd==cmd_ok)
{
String str =list.getString(list.getSelectedIndex());

if(str.equals("Meditation"))
{
//System.out.println("11111111111");
//NewThread nt=new NewThread();
show_meditation_screen();

}
}
}
public class NewThread extends Thread
{
public NewThread()
{
start();
}
public void run()
{
try
{


show_meditation_screen();
}
catch(Exception e)
{
e.printStackTrace();
}

}
}
public void show_meditation_screen()
{
MeditationMidlet Medi = new MeditationMidlet(this);
Medi.show();
}
}

//////////////////////////// Second program

package Meditation;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.media.Player;
import java.io.*;
import java.util.*;
import Home.HomeMidlet;


/**
*
* @author krupa
* @version
*/
public class MeditationMidlet extends MIDlet implements CommandListener {
private Display disp;
private Form Meditation_frm;
private Command cmd_play;
private Command cmd_exit;
private Image image;
private ImageItem imageitem;
private Command cmd_stop;
private HomeMidlet Home;

public MeditationMidlet(HomeMidlet home)
{
try
{
this.Home = home;

disp=Display.getDisplay(home);
Meditation_frm = new Form("Meditation");
cmd_play=new Command("Play",Command.OK,1);
cmd_stop=new Command("Stop",Command.SCREEN,2);
cmd_exit= new Command("Exit",Command.EXIT,2);

image = Image.createImage("/Meditation/m2.gif");
imageitem = new ImageItem(null,image,ImageItem.LAYOUT_CENTER,"meditation");
Meditation_frm.append(imageitem);

Meditation_frm.addCommand(cmd_play);
Meditation_frm.addCommand(cmd_stop);
Meditation_frm.addCommand(cmd_exit);
Meditation_frm.setCommandListener(this);
}
catch(Exception e)
{

}



}
public void startApp()
{

}
public void show() {
disp.setCurrent(Meditation_frm);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
public void commandAction(Command cmd,Displayable dis)
{
try
{
InputStream in = getClass().getResourceAsStream("/Meditation/6.wav");
Player player = Manager.createPlayer(in, "audio/X-wav");

if(cmd==cmd_play)
{

player.setLoopCount(5);
player.start();
}
if(cmd==cmd_stop)
{
player.stop();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me help me help me
 
Similar Threads
Referencing a method form another class?
How to run .lang package in J2ME
Why won't my BACK BUTTON work?
Ticker on mobile
Help with switching between forms