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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:55:29+00:00 2026-05-30T14:55:29+00:00

Below class is a textbox field. Can this be modified so that when the

  • 0

Below class is a textbox field. Can this be modified so that when the textbox is filled with text and user keeps type the text then scrolls ? Whats happening now is that once the textbox is filled with text any subsequent text that is typed is not being displayed.

Thanks

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.EditField;

public class CustomEditField extends EditField {
    // private members of the CustomEditField class
    private Font defaultFont;
    // used to get the default font
    private String text;

    // used to specify the default width of the table cells

    // constructor calls the super class constructor
    public CustomEditField(String label, String initialValue, int maxNumChars,
            long style) {
        super(label, initialValue, maxNumChars, style);
    }

    // overrides the default getPreferredWidth functionality to return a fixed
    // width
    public int getPreferredWidth() {
        defaultFont = Font.getDefault();
        text = "0000000000";
        return defaultFont.getAdvance(text);

    }

    // overrides the default layout functionality to set the width of the table
    // cell
    protected void layout(int width, int height) {
        width = getPreferredWidth();
        height = super.getPreferredHeight();
        super.layout(width, height);
        // uses the super class' layout functionality
        // after the width and the height are set
        super.setExtent(width, height);
        // uses the super class' setExtent functionality
        // after the width and the height are set
    }

    public void paint(Graphics graphics){

        graphics.setBackgroundColor(Color.LIGHTBLUE);
        super.paint(graphics);
    }

}
  • 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-30T14:55:30+00:00Added an answer on May 30, 2026 at 2:55 pm

    This will help you to get started. It is a simplified version of the ScrollableEditField that I am using. I coded it before touch BlackBerry devices became available, therefore some additional work is required here to support TouchEvents.

    class ScrollableEditField extends Manager {
        private final static int        DEFAULT_TOP_PADDING     = 1;
        private final static int        DEFAULT_BOTTOM_PADDING  = 1;
        private final static int        DEFAULT_LEFT_PADDING    = 1;
        private final static int        DEFAULT_RIGHT_PADDING   = 1; 
    
        private int                     TOTAL_VERTICAL_PADDING  = DEFAULT_TOP_PADDING + DEFAULT_BOTTOM_PADDING;
        private int                     TOTAL_HORIZONTAL_PADDDING = DEFAULT_LEFT_PADDING + DEFAULT_RIGHT_PADDING;
    
        private int                     width  = -1;
        private int                     height = -1;
    
        private HorizontalFieldManager  hfm = new HorizontalFieldManager(HORIZONTAL_SCROLL);
        private EditField               ef;
    
        public ScrollableEditField(String label, String initialValue, int maxNumChars, long innerEditFieldStyle) {
            super(NO_HORIZONTAL_SCROLL);
            ef = new EditField(label, initialValue, maxNumChars, innerEditFieldStyle);
            hfm.add(ef);
            add(hfm);
        }
    
        protected void sublayout(int width, int height) {
            if (this.width != -1) {
                width = this.width;
            }
    
            if (this.height != -1) {
                height = this.height;
            } else {
                height = ef.getFont().getHeight();
            }
    
            layoutChild(hfm, width-TOTAL_HORIZONTAL_PADDDING, height-TOTAL_VERTICAL_PADDING);
            setPositionChild(hfm, DEFAULT_LEFT_PADDING, DEFAULT_TOP_PADDING);
            setExtent(width, height);
        }    
    
        public EditField getEditField() {
            return ef;
        }
    
        public void setWidth(int width) {
            this.width = width;
        }
    
        protected void onFocus(int direction) {
            super.onFocus(direction);
            ef.setCursorPosition(0);
        }
    
        protected void onUnfocus() {
            hfm.setHorizontalScroll(0);
            super.onUnfocus();
        }
    };
    
    public class ScrollableEditFieldScreen extends MainScreen {
        public ScrollableEditFieldScreen() {
            super(NO_VERTICAL_SCROLL);
            setTitle("ScrollableEditField");
    
            // hfm1 and hfm2 are here just to position the ScrollableEditField in the center of the screen
            HorizontalFieldManager hfm1 = new HorizontalFieldManager(USE_ALL_HEIGHT | FIELD_HCENTER);
            HorizontalFieldManager hfm2 = new HorizontalFieldManager(FIELD_VCENTER);
    
            // instantiating the scrollable edit field and adding border
            ScrollableEditField sef = new ScrollableEditField("", "", 50, 0);
            sef.setBorder(BorderFactory.createRoundedBorder(new XYEdges(5,5,5,5)));
            sef.setWidth(sef.getFont().getAdvance('0')*10);
    
            hfm2.add(sef);
            hfm1.add(hfm2);
            add(hfm1);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model defined as below: class Example(models.Model): user = models.ForeignKey(User, null=True) other
I have three model classes that look as below: class Model(models.Model): model = models.CharField(max_length=20,
I'm getting this error message with the code below: class Money { public: Money(float
Consider the class below that represents a Broker: public class Broker { public string
I'm having problem automating to type the text in the textbox with variable id's
The line below works for the TextBox DP Text , where CellNo is a
The code below works fine but, in the textbox the decimal value has this
Update is below code chunks. Original Question: I have an input field that is
My code is below, it outputs what the user is typing in the text
i need Enumarable value from below class but give error public static Enumerable LoadDataByName(string

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.