| Reply | « Previous Thread | Next Thread » |
|
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. |
| littlenexo |
| View Public Profile |
| Find all posts by littlenexo |
|
You can't have Commands on a FullCanvas, so addCommand() throws an IllegalStateException.
shmoove |
|
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.
|
|
Join Date: Dec 2005
Posts: 1,696
Location: Europe/Poland/Warsaw
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 |
| peterblazejewicz |
| View Public Profile |
| Find all posts by peterblazejewicz |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|