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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:34:20+00:00 2026-06-01T10:34:20+00:00

I am use a button and when u click this button a text field

  • 0

I am use a button and when u click this button a text field is automatic created and button status is automatic disable but if u click on disable button text field is automatic delete and button status is changed to enable.i going through this process.

public class ConfigurationScreen extends MainScreen implements FieldChangeListener{
    TextField tf_text;
    tf_text =  new TextField(TextField.TYPE_PLAIN,img_text[1],img_text[0],TextField.FIELD_HCENTER);
    tf_text.setWidth(Display.getWidth()/2+20);

    ImageButton btn_en;
    btn_en = new ImageButton(imgs_tmintrvl1,"enable",ImageButton.FIELD_HCENTER);

    ImageButton btn_dis;
    btn_dis=new ImageButton(imgs_tmintrvl1,"Disable",ImageButton.FIELD_HCENTER); 

    add(btn_en);

    btn_en.setChangeListener(this);

    public void fieldChanged(Field field, int context) {
        if( field==btn_en)
        {
            delete(btn_en);
            insert(btn_dis, 4);
            insert(tf_text, 5);

            System.out.println(ex);
        }else if (field == btn_dis){
            delete(btn_dis);
            delete(tf_text);
            insert(btn_en, 4);

            System.out.println("Disable Button="+ex);
        }
    }    

But when i run this code i am getting null pointerr exception please help me where i am making mistake.

  • 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-01T10:34:22+00:00Added an answer on June 1, 2026 at 10:34 am
    package org.maxmobility.wmp.beta;
    
    import com.maxmobility.customfield.H_FieldManager;
    import com.maxmobility.customfield.ImageButton;
    import com.maxmobility.customfield.LabelField;
    import com.maxmobility.customfield.PillButtonField;
    import com.maxmobility.customfield.PillButtonSet;
    import com.maxmobility.customfield.TextArea;
    import com.maxmobility.customfield.TextField;
    import com.maxmobility.util.AppColors;
    
    import net.rim.device.api.collection.List;
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.system.EncodedImage;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.FocusChangeListener;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.container.HorizontalFieldManager;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.ui.decor.Background;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    
    public class ConfigurationScreen  extends MainScreen implements FieldChangeListener{
    
        TextField tf_phn1;
        TextField tf_phn2; 
        TextField tf_msg; 
        TextArea ta_msg;
        ImageButton btn_add;
        ImageButton btn_subtract;
        ImageButton btn_en;
        ImageButton btn_dis;
        ImageButton btn_time1, btn_time2, btn_time3;
        LabelField lf_msg;
        LabelField lf_time;
        LabelField lf1,lf2,lf3,lf4;
        private Bitmap[] imgs_addbtn;
        private Bitmap[] imgs_subbtn;
        private Bitmap[] imgs_tmintrvl1;
        private Bitmap[] imgs_tmintrvl2;
        private Bitmap[] imgs_tmintrvl3;
        private EncodedImage[] img_text;
        private H_FieldManager hfm1 , hfm2;
        private HorizontalFieldManager hfm3,hfm4;
        private VerticalFieldManager vfm;
        private boolean show = false;
        PillButtonField pbf1;
        PillButtonField pbf2;
        PillButtonField pbf3;
        PillButtonSet pbf_set;
    
        public ConfigurationScreen(){
            super(USE_ALL_HEIGHT | USE_ALL_WIDTH);
            Background background = BackgroundFactory
                    .createSolidBackground(AppColors.APP_BG);
            this.getMainManager().setBackground(background);
    
            LabelField lf = new LabelField("Configuration Screen", LabelField.FIELD_HCENTER | LabelField.USE_ALL_WIDTH);
            lf.setColor(Color.RED);
            setTitle(lf);
    
             img_text = new EncodedImage[2];
             img_text[0] = EncodedImage.getEncodedImageResource("edittext_selected.png");
             img_text[1] = EncodedImage.getEncodedImageResource("edittext.png");
    
            imgs_addbtn =  new Bitmap[3];
            imgs_addbtn[0] = Bitmap.getBitmapResource("btn_add_sub.png");
            imgs_addbtn[1] = Bitmap.getBitmapResource("btn_add_subfocused.png");
            imgs_addbtn[2] = Bitmap.getBitmapResource("btn_add_subfocused.png");
    
            imgs_subbtn =  new Bitmap[3];
            imgs_subbtn[0] = Bitmap.getBitmapResource("btn_add_sub.png");
            imgs_subbtn[1] = Bitmap.getBitmapResource("btn_add_subfocused.png");
            imgs_subbtn[2] = Bitmap.getBitmapResource("btn_add_subfocused.png");
    
            imgs_tmintrvl1 =  new Bitmap[3];
            imgs_tmintrvl1[0] = Bitmap.getBitmapResource("default_btn_Unfocused.png");
            imgs_tmintrvl1[1] = Bitmap.getBitmapResource("default_btn_focused.png");
            imgs_tmintrvl1[2] = Bitmap.getBitmapResource("default_btn_focused.png");
    
    //        imgs_tmintrvl2 =  new Bitmap[3];
    //        imgs_tmintrvl2[0] = Bitmap.getBitmapResource("default_btn_Unfocused.png");
    //        imgs_tmintrvl2[1] = Bitmap.getBitmapResource("default_btn_focused.png");
    //        imgs_tmintrvl2[2] = Bitmap.getBitmapResource("default_btn_focused.png");
    //        
    //        imgs_tmintrvl3 =  new Bitmap[3];
    //        imgs_tmintrvl3[0] = Bitmap.getBitmapResource("default_btn_Unfocused.png");
    //        imgs_tmintrvl3[1] = Bitmap.getBitmapResource("default_btn_focused.png");
    //        imgs_tmintrvl3[2] = Bitmap.getBitmapResource("default_btn_focused.png");
    //        
            tf_phn1 = new TextField(TextField.TYPE_PHONE,img_text[1],img_text[0],TextField.FIELD_LEFT);
            tf_phn2 = new TextField(TextField.TYPE_PHONE,img_text[1],img_text[0],TextField.FIELD_LEFT);
            tf_msg = new TextField(TextField.TYPE_PLAIN,img_text[1],img_text[0],TextField.FIELD_HCENTER);
            tf_phn1.setWidth(Display.getWidth()/2+50);
            tf_phn2.setWidth(Display.getWidth()/2+50);
            tf_msg.setWidth(Display.getWidth()/2+95);
    
            ta_msg = new TextArea(Display.getWidth()/2+130, 100,TextArea.FIELD_HCENTER);
    
             btn_add = new ImageButton(imgs_addbtn," +",ImageButton.FIELD_HCENTER);
             btn_subtract = new ImageButton(imgs_subbtn," -",ImageButton.FIELD_RIGHT);
             btn_en = new ImageButton(imgs_tmintrvl1,"Enable",ImageButton.FIELD_HCENTER);
             btn_dis = new ImageButton(imgs_tmintrvl1,"Disable",ImageButton.FIELD_HCENTER);
    //       btn_time1 = new ImageButton(imgs_tmintrvl1, "15 min",ImageButton.FIELD_LEFT);
    //       btn_time2 = new ImageButton(imgs_tmintrvl1, "30 min",ImageButton.FIELD_HCENTER);
    //       btn_time3 = new ImageButton(imgs_tmintrvl1, "45 min",ImageButton.FIELD_RIGHT);
    //       btn_time1.set_Margin(35,0, 0,0);
    //       btn_time2.set_Margin(0,0, 0,0);
    //       btn_time3.set_Margin(0,0, 0,0);
             //btn_add.set_Margin(0,0, 8,8);
             LabelField lf1 = new LabelField("",Display.getWidth(),45,LabelField.FIELD_LEFT);
             LabelField lf2 = new LabelField("",Display.getWidth(),45,LabelField.FIELD_LEFT);
             LabelField lf3 = new LabelField("",Display.getWidth(),45,LabelField.FIELD_LEFT);
             LabelField lf4 = new LabelField("",Display.getWidth(),45,LabelField.FIELD_LEFT);
             lf_msg = new LabelField("Alert Message",LabelField.FIELD_LEFT);
             lf_msg.set_pos(35,0);
             lf_time = new LabelField("Select Time Interval",LabelField.FIELD_LEFT);
             lf_time.set_pos(35,20);
    
             pbf1 = new PillButtonField("15 min");
             pbf2 = new PillButtonField("30 min");
             pbf3 = new PillButtonField("45 min");
             pbf_set = new PillButtonSet(300,40);
             pbf_set.add(pbf1);
             pbf_set.add(pbf2);
             pbf_set.add(pbf3);
    
            hfm1 = new H_FieldManager(tf_phn1, btn_add, true, H_FieldManager.FIELD_HCENTER);
            hfm2 = new H_FieldManager(tf_phn2, btn_subtract, true, H_FieldManager.FIELD_HCENTER);
           // hfm3 = new HorizontalFieldManager(HORIZONTAL_SCROLL_MASK);
            hfm4 = new HorizontalFieldManager(pbf1.FIELD_HCENTER);
    //        hfm3.add(btn_time1);
    //        hfm3.add(btn_time2);
    //        hfm3.add(btn_time3);
            hfm4.add(pbf_set);
            vfm = new VerticalFieldManager();
    
            add(lf1);
            add(hfm1);
            add(lf_msg);
            //add(tf_msg);
            add(ta_msg);
            add(btn_en);
            add(lf_time);
            //add(hfm3);
            add(hfm4);
            System.out.println(" insert label");
    
    
            btn_add.setChangeListener(this);
            btn_subtract.setChangeListener(this);
            btn_en.setChangeListener(this);
            btn_dis.setChangeListener(this);
    
        }
        public void fieldChanged(Field field, int context) {
            // TODO Auto-generated method stub
            if(field == btn_add){
                insert(hfm2, 2);
    
            }else if(field == btn_subtract){
                delete(hfm2);
            //}
                }else if(field == btn_en){
                    replace(btn_en, btn_dis);
    
                    insert(tf_msg, 5);
    
                }else if(field == btn_dis){
                    replace(btn_dis, btn_en);
                    delete(tf_msg);
                }
        }
    
    
    }
    
    I hope your Problem will solve in this code.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Typical jQuery over-use: $('button').click(function() { alert('Button clicked: ' + $(this).attr('id')); }); Which can be
When user click on button , I want to clear text field. How can
I use this to hide keyboard when i click done button or outside of
If the user manually clicks the 'submit' button, i use this code: if (isset($_POST['submit_findall']))
I'm trying to use strtotime() to respond to a button click to advance -1
I am trying to use some action when I click button in navigation controller.
This does not work the way I want to. currently, the text field activates
I'm dynamically adding rows/fields in this code. I have a text field for the
hi can anyone tell me how a text field is generated when a button
Is there a way to use the value from a text field as 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.