Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:50:45+00:00 2026-05-30T18:50:45+00:00

I have a class which extends canvas.I created one more canvas class. But I

  • 0

I have a class which extends canvas.I created one more canvas class. But I couldn’t switch between them.

Is it possible to switching between canvases in J2ME?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:50:46+00:00Added an answer on May 30, 2026 at 6:50 pm
    import ...
    public class MyMIDlet extends MIDlet{
        ...
        final Canvas1 c1;
        final Canvas2 c2;
        ...
        public MyMIDlet(){
            c1 = new Canvas1(this);
            c2 = new Canvas2(this);
        }
        ...
    }
    
    import ...
    public class Canvas1 extends Canvas implements CommandListener{
        MyMIDlet myMidlet;
        Display disp;
        Command switchDisp;
        ...
        /**
        *constructor
        */
        public Canvas1(MyMIDlet myMidlet){
            this.MyMIDlet = myMidlet;
            disp = myMidlet.getDisplay();
            switchDisp = new Command("switch", Command.SCREEN, 0);
            this.addCommand(switchDisp);
            this.setCommandListener(this);
        }
        ...
        public void paint(Graphics g){
            g.setColor(255,255,255);
            g.drawString("canvas1", 0, 0, 0);
        }
        ...
        public void commandAction(Command cmd, Displayable displayable){
            disp.setCurrent(myMidlet.c2);
        }
    }
    
    import ...
    public class Canvas2 extends Canvas implements CommandListener{
        MyMIDlet myMidlet;
        Display disp;
        Command switchDisp;
        ...
        /**
        *constructor
        */
        public Canvas1(MyMIDlet myMidlet){
            this.MyMIDlet = myMidlet;
            disp = myMidlet.getDisplay();
            switchDisp = new Command("switch", Command.SCREEN, 0);
            this.addCommand(switchDisp);
            this.setCommandListener(this);
        }
        ...
        public void paint(Graphics g){
            g.setColor(255,255,255);
            g.drawString("canvas2", 0, 0, 0);
        }
        ...
        public void commandAction(Command cmd, Displayable displayable){
            disp.setCurrent(myMidlet.c1);
        }
    }   
    

    Displayable object is an object that has the capability of being placed on the display. A Displayable class implements Displayable interface.
    The Display class is the display manager that is instantiated for each active MIDlet and provides methods to retrieve information about the device’s display capabilities. A canvas is made visible by calling the Display.setCurrent() method.
    A canvas implements the Displayable interface.
    A Displayable class is a UI element that can be shown on the device’s screen while the Display class abstracts the display functions of an actual device’s screen and makes them available to you. It provides methods to show or change the current UI element that you want displayed. Thus, a MIDlet shows a Displayable UI element on a Display using the setCurrent(Displayable element) method of the Display class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom class loader which extends from a URLClassLoader. I added a
I have a view in Eclipse (implemented by a class which extends org.eclipse.ui.part.ViewPart )
I have 2 web user controls, both inherit the same base class which extends
I have two Java classes: B, which extends another class A, as follows :
I have a class which extends JFrame and forms the GUI of my program.
Suppose i have a class which extends ViewGroup public class MapView extends ViewGroup It
I have Class which extends JDialog . Have an another JDialog declared inside the
I have a class which extends android.app.Application , which I use to persist global
I have Packet class contains virtual method and I have LogInRequest class which extends
I have a MyNameSpace_View_Helper_FormErrors Class which extends the standard FormErrors Class and sets the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.