BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 11-08-2006, 01:48 PM   #1
santa kruz
New Member
 
Join Date: Nov 2006
Model: 8700g
Posts: 7
Default displaying 2 editFields side-by-side

Please Login to Remove!

Hi,

I'm having a lot of trouble trying to display two EditFields side-by-side. I try the following:

HorizontalFieldManager hfm = new HorizontalFieldManage(HORIZONTAL_SCROLL);
BasicEditField befA = new BasicEditField("ab","",4,EditField.FILTER_NUMERIC) ;
BasicEditField befB = new BasicEditField("cd","",4,EditField.FILTER_NUMERIC) ;
hfm.add(befA);
hfm.add(befB);
add(hfm);

But when I do this, I can see befA on the screen, and the screen can scroll over to the right, but I never see the label fro befB. I can enter numbers into befB, although I can't see them.

Thanks for all the help!

Sunny.
Offline  
Old 11-08-2006, 02:02 PM   #2
santa kruz
New Member
 
Join Date: Nov 2006
Model: 8700g
Posts: 7
Default

I got it! Found it on the blackberry developper site.

Sorry for all the posts, i'm just having a bunch of problems with this program (I'm a noob).

Here's how i got it to work for anyone else having the same problem:

//main class for FixedWidthField which extends the EditField class
class FixedWidthField extends EditField
{
//private members of the FixedWidthField 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
FixedWidthField(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
}

}
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Implement Whisker Switch  picture

Implement Whisker Switch

$50.00



ELECTRIC COOLING FAN GROUND-ING THERMO-STAT SWITCH RADIATOR TEMP-ERATURE SENSOR picture

ELECTRIC COOLING FAN GROUND-ING THERMO-STAT SWITCH RADIATOR TEMP-ERATURE SENSOR

$17.99



Vertical Float Switch: Sump Accessory -  picture

Vertical Float Switch: Sump Accessory -

$17.99



Dusk to Dwan/Day Night Sensor, Photoelectric Switch, Photo Cell Sensor 110-277V picture

Dusk to Dwan/Day Night Sensor, Photoelectric Switch, Photo Cell Sensor 110-277V

$49.28



Square D 9013FSG2J21 Water Pump Pressure Switch, 30/50 PSI, DPST 9013 picture

Square D 9013FSG2J21 Water Pump Pressure Switch, 30/50 PSI, DPST 9013

$21.88



P3 100/V/SVB  MOELLER. EATON P3-100/V/SVB. BASE MOUNT 100 AMPS. SWITCH picture

P3 100/V/SVB MOELLER. EATON P3-100/V/SVB. BASE MOUNT 100 AMPS. SWITCH

$174.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.