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

  • Home
  • SEARCH
  • 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 3597170
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:05:01+00:00 2026-05-18T20:05:01+00:00

I want to store each character that is input from user. When user presses

  • 0

I want to store each character that is input from user. When user presses key, that key should store in any variable. When user presses other key, it must replace the value of variable with new character in textbox 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-18T20:05:02+00:00Added an answer on May 18, 2026 at 8:05 pm

    yes you need to listen event ItemStateListener and then you can handle it in itemStateChanged(..) Here is full code

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package hello;
    
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    
    /**
     * @author Jigar
     */
    public class KeyEventListener extends MIDlet implements ItemStateListener{
    
        private boolean midletPaused = false;
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">
        private Form form;
        private TextField textField;
        //</editor-fold>
    
        /**
         * The KeyEventListener constructor.
         */
        public KeyEventListener() {
        }
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">
        //</editor-fold>
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">
        /**
         * Initilizes the application.
         * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
         */
        private void initialize() {
            // write pre-initialize user code here
    
            // write post-initialize user code here
        }
        //</editor-fold>
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">
        /**
         * Performs an action assigned to the Mobile Device - MIDlet Started point.
         */
        public void startMIDlet() {
            // write pre-action user code here
            switchDisplayable(null, getForm());
            // write post-action user code here
        }
        //</editor-fold>
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">
        /**
         * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
         */
        public void resumeMIDlet() {
            // write pre-action user code here
    
            // write post-action user code here
        }
        //</editor-fold>
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">
        /**
         * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
         * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
         * @param nextDisplayable the Displayable to be set
         */
        public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
            // write pre-switch user code here
            Display display = getDisplay();
            if (alert == null) {
                display.setCurrent(nextDisplayable);
            } else {
                display.setCurrent(alert, nextDisplayable);
            }
            // write post-switch user code here
        }
        //</editor-fold>
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">
        /**
         * Returns an initiliazed instance of form component.
         * @return the initialized component instance
         */
        public Form getForm() {
            if (form == null) {
                // write pre-init user code here
                form = new Form("form", new Item[] { getTextField() });
                form.setItemStateListener(this);
            }
            return form;
        }
        //</editor-fold>
    
        //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField ">
        /**
         * Returns an initiliazed instance of textField component.
         * @return the initialized component instance
         */
        public TextField getTextField() {
            if (textField == null) {
                // write pre-init user code here
                textField = new TextField("textField", null, 32, TextField.ANY);
    
            }
            return textField;
        }
        //</editor-fold>
    
        /**
         * Returns a display instance.
         * @return the display instance.
         */
        public Display getDisplay () {
            return Display.getDisplay(this);
        }
    
        /**
         * Exits MIDlet.
         */
        public void exitMIDlet() {
            switchDisplayable (null, null);
            destroyApp(true);
            notifyDestroyed();
        }
    
        /**
         * Called when MIDlet is started.
         * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
         */
        public void startApp() {
            if (midletPaused) {
                resumeMIDlet ();
            } else {
                initialize ();
                startMIDlet ();
            }
            midletPaused = false;
        }
    
        /**
         * Called when MIDlet is paused.
         */
        public void pauseApp() {
            midletPaused = true;
        }
    
        /**
         * Called to signal the MIDlet to terminate.
         * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
         */
        public void destroyApp(boolean unconditional) {
        }
    
        public void itemStateChanged(Item item) {
            if(item.equals(getTextField())){
                System.out.println("KeyPressed :) ");
            }
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to store each character that is input from user. When user presses
I want to read each line from a text file and store them in
I want to store the images related to a each person's profile in the
I want to store a row in an SQLite 3 table for each booking
I want to store the current URL in a session variable to reference the
I want to store a large result set from database in memory. Every record
I want to store buttons in some sort of collection, arraylist, so that I
I want to store a large number of sound files in a database, but
I want to store the data returned by $_SERVER[REMOTE_ADDR] in PHP into a DB
I want to store a a c# DateTimeOffset value in a SQL Server 2005

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.