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 7870339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:35:29+00:00 2026-06-03T01:35:29+00:00

I am trying to make a class that can set what is on the

  • 0

I am trying to make a class that can set what is on the screen (Like set a Form to the Display, what ever.) outside the midlet (Main) class
So I thought I have to enter and change the Main‘s variable display, but I went to an error.

Here’s the whole program:

//Main.java
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Main extends MIDlet {

    public Other othr = new Other(this);
    public Display display = Display.getDisplay(this);
    public void startApp() {
        display.setCurrent(othr);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}

//Other.java
import javax.microedition.lcdui.*;
public class Other extends Canvas{

    Form a = new Form("a");
    public TextEdit(Main mc){
        //HERE IT IS!
        mc.display.getDisplay(mc).setCurrent(a);
        //If I comment out the above, I get no error.

    }
    protected void paint(Graphics g) {
         //Nothing yet
    }

}

And I always get the error “The application has unexpectedly quit”.

I also tried to replace mc.display.getDisplay(mc).setCurrent(a); with Display.getDisplay(mc).setCurrent(a);, error is not showed then, but Form a isn’t displayed at all.

It’s likely to be a stupid mistake, but I’m lost

What can I do?

  • 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-06-03T01:35:30+00:00Added an answer on June 3, 2026 at 1:35 am

    It’s a small mistake in your code. Make changes in your code like following.

    //Main.java
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class Main extends MIDlet {
    
        public Other othr ;
        public Display display ;
        public void startApp() {
             display= Display.getDisplay(this);
            othr=new Other(this);
            display.setCurrent(othr);
        }
    
        public void pauseApp() {
        }
    
        public void destroyApp(boolean unconditional) {
        }
    }
    

    and check your Other look like this, make sure what you want Form or Canvas both are different.

    For Form your code like this

    //Other.java
    import javax.microedition.lcdui.*;
    public class Other {
    
        Form a ;
        public Other(Main mc){
            //HERE IT IS!
           a=new Form("a");
            Display.getDisplay(mc).setCurrent(a);
            //If I comment out the above, I get no error.
    
        }
    
    }
    

    For Canvas check this one

    /Other.java
    import javax.microedition.lcdui.*;
    public class Other extends Canvas{
    
         public Other(Main mc){
            //HERE IT IS!
            Display.getDisplay(mc).setCurrent(this);
            //If I comment out the above, I get no error.
    
        }
        protected void paint(Graphics g) {
             //Nothing yet
        }
    
    }
    

    This will help you, Note:: Check difference between Canvas & Forms.

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

Sidebar

Related Questions

I'm trying to build a small class-like container that will make it a little
I'm trying to make a set of custom tags that encapsulate form elements (markup
I'm trying to make a button class (abstract) so I can set what function
I'm trying to make a Parallel Helper class ( ParallelRunner ) that can be
I'm trying to make a class that is borg-like. I'd like one particular property
I am trying to extend the mysqli class to make a helper class that
A am trying to make a program that takes a signal from one class
I am trying to make a ScrolledWindow that can scroll over a grid of
I'm trying to make an application that can store a tree structure with files
I am trying to make a game object that can be made semitransparent during

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.