473,772 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

J2ME Novice: Screen Navigation?

How do you navigate between screens in J2ME? I would like to navigate to the
next screen using the default emulator in KToolbar. Here is a snippit of my
commandAction method:
public void commandAction(C ommand c, Displayable s) {
if (c == mMenuCommand)
{
mMenuForm = new Form("SampleMID let");
final String[] menuItems = { "Games" , "Calculator ", "Alarm Clock" };
final List list = new List("Select a Item", List.IMPLICIT, menuItems, null);

final Command nextCommand = new Command("Next", Command.SCREEN, 0);
Command quitCommand = new Command("Quit", Command.SCREEN, 0);
list.addCommand (nextCommand);
list.addCommand (quitCommand);
list.setCommand Listener(new CommandListener ()
{
public void commandAction(C ommand c, Displayable s)
{
if (c == nextCommand || c == List.SELECT_COM MAND)
{
int index = list.getSelecte dIndex();
System.out.prin tln("Your selection: " + menuItems[index]);

// Move on to the next screen. Here, we just exit.
notifyDestroyed ();
} else notifyDestroyed ();
}
});
Display.getDisp lay(this).setCu rrent(list);
}

if (c == mExitCommand) notifyDestroyed ();
}

Thanks!
Gilgantic
Jul 17 '05 #1
7 9137
gilgantic wrote:
How do you navigate between screens in J2ME?


See the Javadoc for javax.microedit ion.lcdui.Displ ay.setCurrent for more
information.

--
Darryl L. Pierce <mc******@myrea lbox.com>
Visit the Infobahn Offramp - <http://bellsouthpwp.ne t/m/c/mcpierce>
"What do you care what other people think, Mr. Feynman?"
Jul 17 '05 #2
gilgantic wrote:
How do you navigate between screens in J2ME? <snip>


Sorry, I didn't read your entire message previously. You have to explicitly
tell the Display what the Displayable is that you want to show. There's no
way in the MIDP to tell the VM what the screens are and in what order they
should be displayed.

--
Darryl L. Pierce <mc******@myrea lbox.com>
Visit the Infobahn Offramp - <http://bellsouthpwp.ne t/m/c/mcpierce>
"What do you care what other people think, Mr. Feynman?"
Jul 17 '05 #3
"Darryl L. Pierce" <mc******@myrea lbox.com> wrote in message news:<d9******* *************** ********@free.t eranews.com>...
gilgantic wrote:
How do you navigate between screens in J2ME? <snip>


Sorry, I didn't read your entire message previously. You have to explicitly
tell the Display what the Displayable is that you want to show. There's no
way in the MIDP to tell the VM what the screens are and in what order they
should be displayed.


Well are there any online examples of an entire application. The ones I have
seen just have minimum amount of navigation. I will check into the javadoc
for the Display class.
Jul 17 '05 #4
gilgantic wrote:
> How do you navigate between screens in J2ME? <snip>


Sorry, I didn't read your entire message previously. You have to
explicitly tell the Display what the Displayable is that you want to
show. There's no way in the MIDP to tell the VM what the screens are and
in what order they should be displayed.


Well are there any online examples of an entire application. The ones I
have
seen just have minimum amount of navigation. I will check into the
javadoc for the Display class.


There's not really much to it. In your commandAction() method, you
determine which command the user selected and then programmaticall y set the
next Displayable by calling:

Display.getDisp lay([reference to your MIDlet]).setCurrent([the Displayable])

There's no underlying system for registering Displayables or mapping them,
though such would be a cool side project. :)

--
Darryl L. Pierce <mc******@myrea lbox.com>
Visit the Infobahn Offramp - <http://bellsouthpwp.ne t/m/c/mcpierce>
"What do you care what other people think, Mr. Feynman?"
Jul 17 '05 #5
Ok, I tried this with the following code below, but got the exception listed
below ..

code snippet from MyMidlet
=============== ===============
public void commandAction(
Command c, Displayable d ){
if (c == exitCommand) exitMIDlet();
if (c == selectCommand)
{
Display.getDisp lay(new HelloMIDlet()). setCurrent(d);
}
}

exception during selectCommand
=============== ===============
java.lang.Secur ityException: Application not authorized to access the restricted API

at com.sun.midp.se curity.Security Token.checkIfPe rmissionAllowed (+40)
at com.sun.midp.se curity.Security Token.checkIfPe rmissionAllowed (+7)
at com.sun.midp.mi dletsuite.MIDle tSuiteImpl.chec kIfPermissionAl lowed(+8)
at com.sun.midp.mi dlet.MIDletStat e.<init>(+66)
at javax.microedit ion.midlet.MIDl etProxy.<init>( +5)
at javax.microedit ion.midlet.MIDl et.<init>(+13)
at HelloMIDlet.<in it>(+4)
at MyMIDlet.comman dAction(+27)
at javax.microedit ion.lcdui.Displ ay$DisplayAcces sor.commandActi on(+284)
at javax.microedit ion.lcdui.Displ ay$DisplayManag erImpl.commandA ction(+10
at com.sun.midp.lc dui.DefaultEven tHandler.comman dEvent(+68)
at com.sun.midp.lc dui.AutomatedEv entHandler.comm andEvent(+47)
at com.sun.midp.lc dui.DefaultEven tHandler$Queued EventHandler.ru n(+250)

"Darryl L. Pierce" <mc******@myrea lbox.com> wrote in message news:<ef******* *************** ********@free.t eranews.com>...
gilgantic wrote:
> How do you navigate between screens in J2ME? <snip>

Sorry, I didn't read your entire message previously. You have to
explicitly tell the Display what the Displayable is that you want to
show. There's no way in the MIDP to tell the VM what the screens are and
in what order they should be displayed.


Well are there any online examples of an entire application. The ones I
have
seen just have minimum amount of navigation. I will check into the
javadoc for the Display class.


There's not really much to it. In your commandAction() method, you
determine which command the user selected and then programmaticall y set the
next Displayable by calling:

Display.getDisp lay([reference to your MIDlet]).setCurrent([the Displayable])

There's no underlying system for registering Displayables or mapping them,
though such would be a cool side project. :)

Jul 17 '05 #6
Peace to Darryl and Gilgantic!

I'm not sure what you really mean by Screen Navigation, but if you
mean being able to use the extra buttons such as those on the Nokia
9210i, I did try using the following app, which is the first I tried
to adapt from the provided SDK:

import com.symbian.dev net.crystal.awt .*;
import com.symbian.epo c.awt.*;
import java.awt.*;

class app1 extends CFrame {

EikCommandButto nGroup buttons;
final static int TBUTTON1 = EikCommandButto nGroup.BUTTON1;
final static int TBUTTON2 = EikCommandButto nGroup.BUTTON2;
final static int TBUTTON3 = EikCommandButto nGroup.BUTTON3;
final static int TBUTTON4 = EikCommandButto nGroup.BUTTON4;

public static void main (String args[]) {
new app1();
}

public app1() {
buttons = new EikCommandButto nGroup();
setTitle("Title ");
add(buttons);
buttons.setText (TBUTTON1,"1");
buttons.setText (TBUTTON2,"");
buttons.setText (TBUTTON3,"3");
buttons.setText (TBUTTON4,"Clos e");
buttons.addCBAL istener(new CBAListener() {
public void cbaActionPerfor med (CBAEvent e) {
if (e.getID()==TBU TTON4) {
System.exit(0);
}
}
}
);
}
}

You'll have to download the additional Symbian classes but its worth
it if you can get those buttons to work the magic for you.

"Darryl L. Pierce" <mc******@myrea lbox.com> wrote in message news:<ca******* *************** ********@free.t eranews.com>...
gilgantic wrote:
<snip>
if (c == selectCommand)
{
Display.getDisp lay(new HelloMIDlet()). setCurrent(d);
}

<snip>

No. You can't instantiate a MIDlet to do this job. You have to have a
reference to the currently running MIDlet when attempting to get a Display
reference. The usually pattern is to have a setCurrent(Disp layable) API in
your MIDlet class and set displays that way:

public class FooMIDlet extends MIDlet
{
private static FooMIDlet instance = null;

public FooMIDlet()
{
instance = this;
}

// ....

public static void setCurrent(Disp layable screen)
{
Display.getDisp lay(instance).s etCurrent(scree n);
}
}

Jul 17 '05 #7
From the examples I've seen, and what I've done personally, you should have
a class
that derives from midlet. Create a member variable of type Display in this
class, and
in the StartApp method of your derived class just set the display variable.
Now you always
have access to the display. I think creating a new Midlet inside a midlet
already running might be
your problem, but I'm new to this as well, so I'm not sure about that.

Code

public class Driver extends MIDlet {
Display m_display;
Driver {}
protected void startApp( ) {
m_display = Display.getDisp lay( this );
}
}

Now just pass the m_display variable whenever you need access to the
display. Hope this helps.

Brandon
"gilgantic" <gi*******@yaho o.com> wrote in message
news:d6******** *************** ***@posting.goo gle.com...
Ok, I tried this with the following code below, but got the exception listed below ..

code snippet from MyMidlet
=============== ===============
public void commandAction(
Command c, Displayable d ){
if (c == exitCommand) exitMIDlet();
if (c == selectCommand)
{
Display.getDisp lay(new HelloMIDlet()). setCurrent(d);
}
}

exception during selectCommand
=============== ===============
java.lang.Secur ityException: Application not authorized to access the restricted API
at com.sun.midp.se curity.Security Token.checkIfPe rmissionAllowed (+40)
at com.sun.midp.se curity.Security Token.checkIfPe rmissionAllowed (+7)
at com.sun.midp.mi dletsuite.MIDle tSuiteImpl.chec kIfPermissionAl lowed(+8)
at com.sun.midp.mi dlet.MIDletStat e.<init>(+66)
at javax.microedit ion.midlet.MIDl etProxy.<init>( +5)
at javax.microedit ion.midlet.MIDl et.<init>(+13)
at HelloMIDlet.<in it>(+4)
at MyMIDlet.comman dAction(+27)
at javax.microedit ion.lcdui.Displ ay$DisplayAcces sor.commandActi on(+284)
at javax.microedit ion.lcdui.Displ ay$DisplayManag erImpl.commandA ction(+10
at com.sun.midp.lc dui.DefaultEven tHandler.comman dEvent(+68)
at com.sun.midp.lc dui.AutomatedEv entHandler.comm andEvent(+47)
at com.sun.midp.lc dui.DefaultEven tHandler$Queued EventHandler.ru n(+250)

"Darryl L. Pierce" <mc******@myrea lbox.com> wrote in message

news:<ef******* *************** ********@free.t eranews.com>...
gilgantic wrote:
> > How do you navigate between screens in J2ME? <snip>
>
> Sorry, I didn't read your entire message previously. You have to
> explicitly tell the Display what the Displayable is that you want to
> show. There's no way in the MIDP to tell the VM what the screens are and> in what order they should be displayed.

Well are there any online examples of an entire application. The ones I have
seen just have minimum amount of navigation. I will check into the
javadoc for the Display class.


There's not really much to it. In your commandAction() method, you
determine which command the user selected and then programmaticall y set the next Displayable by calling:

Display.getDisp lay([reference to your MIDlet]).setCurrent([the Displayable])
There's no underlying system for registering Displayables or mapping them, though such would be a cool side project. :)

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3852
by: gilgantic | last post by:
I am trying to discover how to download a J2ME application to a physical cell phone after testing using the emulator. How do I do this? Looking at using Sprint and Motorola for now, but any cell phone will do. Thanks!
6
17295
by: Oz Mortimer | last post by:
Hi, Is there any way that I can scroll a canvas - i.e. if there are too many items on the canvas you can still access by pressing down. I know Form does this (apparently) but I need to do it using a canvas!. Maybe I can attach my Canvas to a form? Ideas? Oz.
0
2288
by: Dave Rathnow | last post by:
We are looking at using J2ME in a embedded device that will be deployed in an industrial application and I've been doing some research to see how practical J2ME would be for our application. Most of the devices I've come across that use J2ME are consumer devices like phones and PDAs. I would be interested in hearing from anyone who might be using J2ME on devices other than consumer type devices. What kind of processor are you using? ...
1
4058
by: Sveta | last post by:
Hi, all! I am new with J2ME. I have application that has form with 2 commands (exit and select). All UI uses are high level API, and it is very important to leave it high-level. This application works fine on some devices. But at Samsung mobile phone, I have a problem. In this phone my 2 commands appear under menu command, and then I can
0
1913
by: 29A | last post by:
Hi, I am new to J2ME, and I need to get the pixel values of the image drawn on screen. What method do I need for this. I found out that PixelGrabber has not implementation in J2ME
3
4676
by: nickyeng | last post by:
I have a j2me application which will be tested on motorola and sony ericsson phone. the j2me application will loads a image PNG format 6.36kb in size and length is 146x38 pixels ON startup for 3 seconds display on screen. it works fine on my Sony Ericsson K610i but it doesn't work in Motorola V3. The error message shows in Motorola V3 is "Application Error". Why is it application error ? How come it works fine on K610i and not...
0
2578
by: WaluigiCubed | last post by:
Hi all, I'm designing a phone application using J2ME that uses the Open Source Diamond Powder methodology. The below getSchema method will eventually read in data to build screens on the phone dynamically from an XML file, but for now I've hard coded the method to do some testing. My code below is working just fine, and it is generating the screen the way I expect it to. public Hashtable getSchema() { Hashtable schema = new...
1
2003
by: WaluigiCubed | last post by:
Hi all, I just have a few small questions related to J2ME (specifically MIDP 2.0) programming. I appreciate any help that I will receive. 1) When I use the LoginScreen Displayable control for a phone application, by default, the user is not able to enter their information directly into the text boxes on the screen. Instead they have to press the circular OK button to bring up a text box to enter their login and password into. Is there...
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.