You Are Here:

Community: Developer Discussion Boards

#1 Old Arrow IllegalStateException thrown when using FullCanvas - 2005-07-21, 10:13

Join Date: Jul 2005
Posts: 1
littlenexo
Offline
Registered User
Hey everybody,

I keep encountering a strange exception everytime I use the Nokia FullCanvas, to get my game fullscreen on MIDP1 phones:
IllegalStateException... which doesn't appear when using traditional Canvas.
Any hint about that? Also isn't there an other way to use fullscreen on Nokia MIDP1 phones?

thank you for your help,

NeXo.
Reply With Quote

#2 Old 2005-07-21, 12:49

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
You can't have Commands on a FullCanvas, so addCommand() throws an IllegalStateException.

shmoove
Reply With Quote

#3 Old Re: IllegalStateException thrown when using FullCanvas - 2006-06-28, 16:04

Join Date: Oct 2004
Posts: 1
4ivonne
Offline
Registered User
The problem is that Nokia-FullCanvas does not support CommandListener. If you call addCommand() or setCommandListener() this results in IllegalStateException.

To use the same command handling for all types of devices (MIDP 2.0, MIPD 1.0, Nokia, non-Nokia) I created my own command handling for MyNokiaCanvas. I store the commands in a list and display this list as a Form when a specific game key is pressed.

public class MyNokiaCanvas extends FullCanvas implements ICanvas {

private Vector commands = new Vector();
private CommandListener listener;

public void setCommandListener(final CommandListener controller) {

try {
super.setCommandListener(controller);
} catch (IllegalStateException e) {
// Nokia FullScreenCanvas does not support setCommandListener()
// store our own listener
listener = controller;
}
}

public void addCommand(final Command command) {

try {
super.addCommand(command);
} catch (IllegalStateException ex) {
// Nokia FullScreenCanvas does not support addCommand()
// store our own command

int i;
for (i = 0; i < commands.size()
&& ((Command) commands.elementAt(i)).getPriority()
< command .getPriority(); i++) ;
commands.insertElementAt(command, i);
}
}

private void displayMenu() {

final List menuList = new List("Menu", List.IMPLICIT);
menuList.addCommand(backCommand);

final Enumeration cmds = commands.elements();
while (cmds.hasMoreElements()) {
final Command cmd = (Command) cmds.nextElement();
menuList.append(cmd.getLabel(), null);
}

// establish commands
menuList.setCommandListener(new CommandListener() {

public void commandAction(final Command command, final Displayable displayable) {

if (command == backCommand) {
displayCanvas();
} else {
final short index = (short) menuList.getSelectedIndex();
displayCanvas();
final Command cmd = (Command) commands.elementAt(index);
listener.commandAction(cmd, null);
}
}
});
Display.getDisplay(midlet).setCurrent(menuList);
}

protected void keyPressed(int k) {

// special handling for Nokia FullScreen:
// use SOFTKEY 1 to display internal menu
if (listener != null && k == FullCanvas.KEY_SOFTKEY1) {
displayMenu();
return;
}

// default key handling in the GUI class
gui.keyPressed(k);
}

}
Last edited by 4ivonne : 2006-06-28 at 16:12.
Reply With Quote

#4 Old Re: IllegalStateException thrown when using FullCanvas - 2006-06-30, 01:17

Join Date: Dec 2005
Posts: 1,696
Location: Europe/Poland/Warsaw
peterblazejewicz
Offline
Super Contributor
hi,

decent docs when using netbeans about using configuration in project for two different platform (includes FullCanvas topic for S40),
http://www.netbeans.org/kb/50/preprocessor-syntax.html

hth,
regards,
Peter
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia