Click here to Skip to main content
12,694,691 members (32,908 online)
Rate this:
Please Sign up or sign in to vote.
See more: Java SE J2ME
I have created a game canvas and a form. I switch control to the GameCanvas using display.setCurrent[<gamecanvas>]</gamecanvas> how do i switch from GameCanvas to Form ? unable to use display.setCurrent? Please help me out.
Posted 22-Sep-11 6:44am
Updated 22-Sep-11 7:19am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to leave some breadcrumbs to find your way back to your Midlet to find its display (and the form). Something along these lines:

public class myMIDlet extends MIDlet implements ... {
Form myForm = new Form( ... 
myGameCanvas ggg = new myGameCanvas(... , this) // <=== note the last parameter - the key to it all

class myGameCanvas extends GameCanvas implements ... {
myMIDlet myHost; // the breadcrumb

    public myGameCanvas(... , myMIDlet host) {
    myHost = host; // remember our host MIDlet

    ... wherever you want to got to the form (probably in a commandAction or keyPressed)
    Display disp = myHost.getDisplay();


If this answers your question, mark it as accepted. Vote anyway.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 22 Sep 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100