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 7901851

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:20:25+00:00 2026-06-03T09:20:25+00:00

I am working on a simple J2ME application and i have a StringItem linked

  • 0

I am working on a simple J2ME application and i have a StringItem linked to a terms and conditions page online.

I have the StringItem setup and it appears underlined (giving the feeling that it is linked); but when i click on it, it does not perform any action.

Find below my code:

public class mobiMidlet extends MIDlet implements CommandListener {

    private Display display;
    private TextField userName,password;
    public Form form;
    private Command login, register, forgot, terms, cancel;
    private Image img_error, img_login, img_register, img_forgot, img_terms;
    private String termsurl = "http://example.com/terms.php";
    private StringItem termsItem;

    public mobiMidlet() {
          form = new Form("Welcome to My App");

          termsItem = new StringItem("", "Terms and Conditions", Item.HYPERLINK);
          termsItem.setDefaultCommand(new Command("terms", Command.ITEM, 1));    

            ItemCommandListener listener = new ItemCommandListener() {
                    public void commandAction(Command cmd, Item item) {
                        if(cmd==terms)
                        {
                            try {
                                platformRequest(termsurl);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                };

            termsItem.setItemCommandListener(listener);        

          userName = new TextField("LoginID:", "", 30, TextField.ANY);
          password = new TextField("Password:", "", 30, TextField.PASSWORD);
          cancel = new Command("Cancel", Command.CANCEL, 2);
          login = new Command("Login", Command.OK, 2);
          try{
            img_login = Image.createImage("/logo.jpg");
            img_register = Image.createImage("/error2.png");
            img_forgot = Image.createImage("/logo.jpg");
            img_register = Image.createImage("/error2.png");
          }catch(Exception e){
            System.out.println(e.getMessage());
          }  
    }


    public void startApp() {
          display = Display.getDisplay(this);
          form.append(termsItem);
          form.append(userName);
          form.append(password);
          form.addCommand(cancel);
          form.addCommand(login);
          form.setCommandListener(this);
          display.setCurrent(form);
    }

    public void commandAction(Command c, Displayable d) {
          String label = c.getLabel();
          if(label.equals("Cancel")) {
              destroyApp(true);
          } else if(label.equals("Login")) {
            validateUser(userName.getString(), password.getString());
          } 
    }
}

How can I fix this so that when I click on the terms and conditions link, it opens the page on a browser?

  • 0 0 Answers
  • 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-03T09:20:27+00:00Added an answer on June 3, 2026 at 9:20 am

    You have not initialized variable terms, so it remains null. Therefore condition cmd==terms is always false and you never enter the if statement.

    Separate line termsItem.setDefaultCommand(new Command("terms", Command.ITEM, 1)); to two:

    terms = new Command("terms", Command.ITEM, 1);
    termsItem.setDefaultCommand(terms);
    

    Now you have a chance.
    BTW why not to debug you program? Run it in emulator, put break point into commandAction and see what happens.

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

Sidebar

Related Questions

I made the simple j2me login application, code is below. It's working perfectly on
Currently i am working in Simple game application, i have a doubt on glVertexAttribPointer
I'm working with my simple PHP captcha algorithm ( http://www.source.ofitall.com/devel/captcha.php ) and I have
I have a simple working PHP script to write an HTML table from a
I am working in simple application in which I need to post data to
I am working on simple application which creates google calendar (under it's own account).
I'm new to Objective-C and I have been working with simple programs, and I
I am trying to convert a working simple Java application to an applet. The
I'm working on simple application on GAE using python2.7,the purpose for this application is
I have a simple 'Working' form that runs on its own thread to keep

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.