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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:12:47+00:00 2026-06-01T03:12:47+00:00

So we are trying to implement 3 text editfields for people to enter their

  • 0

So we are trying to implement 3 text editfields for people to enter their user credentials in our blackberry app. However we are having trouble when the user’s name for example ends up longer than the editfield box (the field must be inside a box and the box must remain stationary, the text must be horizontally scrollable.)

Here is my custom scrollable edit field class based on the scrollable edit field here:

import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.container.HorizontalFieldManager;

public 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); // Maybe not..
}    

public EditField getEditField() {
    return ef;
}

public void setWidth(int width) {
    this.width = width;
}
public void setHeight(int height) {
    this.height = height;
}
protected void onFocus(int direction) {
    super.onFocus(direction);
    ef.setCursorPosition(0);
}

protected void onUnfocus() {
    hfm.setHorizontalScroll(0);
    super.onUnfocus();
}
};

And this is how I use this class in my code:

I put each of these fields into a HorizontalFieldManager and then place this hfm inside a grid cell (with a fixed size). Here are a few lines:

GridFieldManager gfm = new GridFieldManager(1, 2, 0);
gfm.setColumnProperty(0, GridFieldManager.FIXED_SIZE, Display.getWidth()* 1/5);
gfm.setColumnProperty(1, GridFieldManager.PREFERRED_SIZE_WITH_MAXIMUM,    Display.getWidth()* 4/5);

HorizontalFieldManager hfm1e = new HorizontalFieldManager(USE_ALL_WIDTH|USE_ALL_HEIGHT);

ScrollableEditField sef1 = new ScrollableEditField("", "", 32, EditField.FILTER_EMAIL);
sef1.setWidth((Display.getWidth()* 4/5)-5);
sef1.setHeight(getFont().getHeight());
sef1.setBorder(BorderFactory.createRoundedBorder(new XYEdges(1,1,1,1)));
hfm1e.add(sef1);
gfm2.add(hfm1e);

Those last lines are just taken here and there from a much bigger class, however they illustrate the way I am trying to add the custom edit field to the GUI.

Now for some reason, when I run this code the field is there and I can type in it, however its as if the field is one character wide and I cant see anything to the right of it, nor the field or the border. Can anyone help spot what I am doing wrong?

  • 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-01T03:12:49+00:00Added an answer on June 1, 2026 at 3:12 am

    Try this code (I’ve removed some redundant code)

    GridFieldManager gfm = new GridFieldManager(1, 2, 0);
    gfm.setColumnProperty(0, GridFieldManager.FIXED_SIZE, Display.getWidth()* 1/5);
    gfm.setColumnProperty(1, GridFieldManager.PREFERRED_SIZE_WITH_MAXIMUM, Display.getWidth()* 4/5);
    
    ScrollableEditField sef1 = new ScrollableEditField("", "", 32, EditField.FILTER_EMAIL);
    sef1.setBorder(BorderFactory.createRoundedBorder(new XYEdges(1,1,1,1)));
    gfm2.add(sef1);
    

    The size of sef1 is determined by its manager, gfm. Therefore, hfm1e, sef1.setWidth() and sef2.setWindth() are redundant.

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

Sidebar

Related Questions

I am trying to implement a text box that, when the user types something,
I am trying to implement a djapian based full text search for searching user
I am trying to implement my app in different languages. Text changes are fine
Im trying to implement a search function for when the user enters text in
I am trying to implement a wpf user control that binds a text box
I am trying to implement an interface where users can dynamically enter text and
I am trying to implement a control to edit text that will display the
I am trying to implement vectorization of a text file...I have created a dictionary
I'm trying to implement a program similar to 20 Questions, in which a text
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app

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.