BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-29-2011, 08:24 AM   #1
laurre
New Member
 
Join Date: Aug 2011
Model: 7100T
PIN: N/A
Carrier: Az
Posts: 4
Default Display problem overriding ButtonField

Please Login to Remove!

Hello,

I have a problem overriding ButtonField. As the Field.USE_ALL_WIDTH flag doesn't work for ButtonField, I have to extend it.

I just override the layout method like this :

protected void layout(int width, int height) {
setExtent(width, getPreferredHeight());
}

I have several buttons in a VerticalFieldManager. My first button displays correctly, but others are empty (good size, but no text). I have to click the buttons to make the text appear.

Am I missing something ? The problem comes from the layout method I guess, because it's the only method I override.

Thanks !

Edit : Tested on JDE 4.7.0 and 6.0.0, same behaviour

Last edited by laurre; 08-29-2011 at 09:23 AM..
Offline  
Old 08-29-2011, 10:00 AM   #2
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Default Re: Display problem overriding ButtonField

I'm not on a machine where I can look at my layout code at the moment, but IIRC unless the Manager does something about it, layout is called with huge numbers (infinity for practical perposes) for width and height. The text then gets centred between 0 and the huge number. Use the debugger to see what the value for width is to confirm this, but what you probably want to use is Device.getWidth().
__________________
My other Blackberry is a PlayBook.
Offline  
Old 08-29-2011, 10:17 AM   #3
laurre
New Member
 
Join Date: Aug 2011
Model: 7100T
PIN: N/A
Carrier: Az
Posts: 4
Default Re: Display problem overriding ButtonField

I have already debugged : the value for width is 324 (the display's width is 360), and for height 1073741743, but in my case I ignore this last value, so it should be ok...

getPreferredHeight() returns 20 in my case. So the buttons should display correctly, I don't get it !

Last edited by laurre; 08-29-2011 at 10:20 AM..
Offline  
Old 08-30-2011, 07:17 AM   #4
laurre
New Member
 
Join Date: Aug 2011
Model: 7100T
PIN: N/A
Carrier: Az
Posts: 4
Default Re: Display problem overriding ButtonField

It seems that another thing is done in the super.layout() method. Seems to be an internal stuff, for text positioning I think.

The technique I have found, even if it is not the best one I guess :

- don't override layout
- override getPreferredHeight() and getPreferredWidth() :

Code:
public int getPreferredHeight() {
     if (isStyle(USE_ALL_HEIGHT)) {
          return Integer.MAX_VALUE;
     }
     return super.getPreferredHeight();
}

public int getPreferredWidth() {
     if (isStyle(USE_ALL_WIDTH)) {
          return Integer.MAX_VALUE;
     }
     return super.getPreferredWidth();
}
I hope this works in any situations. I know it is not very very clean, if you have a better idea...
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

Similar Threads for: Display problem overriding ButtonField
Thread Thread Starter Forum Replies Last Post
BB Pearl 8120 calendar display problem martin808 General BlackBerry Discussion 0 01-03-2008 07:53 AM
problem with display screen inath General 8100 Series Discussion - Pearl 1 11-18-2007 08:56 AM
Display problem in Desktop Manager crenaud76 General Legacy Device Discussion 1 10-17-2007 01:20 AM
Am I seeing things or is this a display problem? arazu General Legacy Device Discussion 6 08-05-2007 09:48 PM
Display problem Nomads Developer Forum 1 06-25-2007 06:28 AM


Vintage Commodore Amiga A500 Computer System w/Mouse Power Supply & WB 1.3 Disk picture

Vintage Commodore Amiga A500 Computer System w/Mouse Power Supply & WB 1.3 Disk

$375.00



Commodore Amiga 2000 GVP A2000-030 Combo  (40Mhz) 8mb Ram Rev.3 W/ Caddy & Cable picture

Commodore Amiga 2000 GVP A2000-030 Combo (40Mhz) 8mb Ram Rev.3 W/ Caddy & Cable

$635.00



GVP G-Force 040 Combo Rev 6 Accelerator Card for Amiga A2000 33MHz 68040 w/ 8MB picture

GVP G-Force 040 Combo Rev 6 Accelerator Card for Amiga A2000 33MHz 68040 w/ 8MB

$767.00



Vintage Commodore Amiga 1000 RF Modulator In OEM Box picture

Vintage Commodore Amiga 1000 RF Modulator In OEM Box

$38.00



Motorola MC68020RC16E 68020 1C10H Motorola Vintage CPU AMIGA GOLD picture

Motorola MC68020RC16E 68020 1C10H Motorola Vintage CPU AMIGA GOLD

$16.99



Camera Precise Positioning Support Video Record for Acmer Laser Engraving picture

Camera Precise Positioning Support Video Record for Acmer Laser Engraving

$150.78







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