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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:16:23+00:00 2026-05-30T09:16:23+00:00

I am trying to learn J2ME and I have a problem with forms. My

  • 0

I am trying to learn J2ME and I have a problem with forms. My problem is that I have two forms, a ‘main’ form and a ‘greetings’ form. I can’t figure out how to call the ‘greetings ‘form from the’ main’ form. I want once the midlet is launched; the greetings form is called directly by the main form. A sample of my code is shown below.

This code is for the greetings Form (greetingsClass.java)

import javax.microedition.lcdui.*;

public class greetingsClass {

public Display greetingsDisplay;
public Form loginform;

public void login()
{
    loginform = new Form("Login Class Form");
    loginform.append("Ok! Iside login Classs form");
    greetingsDisplay = Display.getDisplay(this);
    greetingsDisplay.setCurrent(loginform);

}
}

This code is for the main form (FormMIDlet.java)

import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;

public class FormMIDlet extends MIDlet {

public Display FormMIDletdisplay;
public Form MainMIDletform;
public LoginClass LoginFormObject;

public void startApp() {
MainMIDletform = new Form("Main Class Form");
MainMIDletform.append("Calling LoginClass Form");
FormMIDletdisplay = Display.getDisplay(this);
FormMIDletdisplay.setCurrent(MainMIDletform);

}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
}

I want the form in the first part of the code (greetingsClass.java)
to be shown in the second part which is the mainform of the midlet (FormMIDlet.java).

  • 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-30T09:16:25+00:00Added an answer on May 30, 2026 at 9:16 am

    I hope this code help you:

    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.*;
    
    
    public class myMidlet extends MIDlet implements CommandListener {
    
        private Form greetings;
        private Form MainForm;
        private Command okCommand;
        Display display;
    
        public myMidlet() {
            display = Display.getDisplay(this);
            greetings = new Form("greetings");
            MainForm = new Form("MainForm");
            okCommand = new Command("Ok", Command.OK, 0);
            MainForm.addCommand(okCommand);
            MainForm.setCommandListener(this);
        }
    
        public void startApp() {
            MainForm.append("This is MainForm");
            display.setCurrent(MainForm);
        }
    
        public void pauseApp() {
        ...
        }
    
        public void destroyApp(boolean unconditional) {
        ...
        }
    
        public void commandAction(Command cmnd, Displayable dsplbl) {
            if (cmnd == okCommand) {
                greetings.append("This is greeting Form");
                display.setCurrent(greetings);
            }
        }
    }   
    

    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 screen is made visible by calling the Display.setCurrent() method.
    A Form is a screen that contains an arbitrary mixture of items (images, text, text fields, choice groups, for instance.)Form is a child of screen and Screen 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 gain information about the screen and 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.A Displayable class implements Displayable interface.
    Displayable object is an object that has the capability of being placed on the display.
    References:
    MIDP GUI Programming
    J2ME Tutorial

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

Sidebar

Related Questions

Trying to learn PL/SQL with multimedia data. Can anyone please point out that from
Trying to learn Regex in Python to find words that have consecutive vowel-consonant or
trying to learn and practice arrays but I have a problem with this small
Trying to learn about php's arrays today. I have a set of arrays like
In trying to learn how to create objects in ActionScript, I have had no
Trying to learn Django, I closed the shell and am getting this problem now
I am currently trying to learn J2ME and build a connect four game (some
Trying to learn jquery here so I took a regular javascript snippet that loops
trying to learn some html/css and I'm having a problem with fixed position divs.
I am trying to learn how to use MSBuild so we can use it

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.