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


Atlas DCA75 Semiconductor Tester with Curve Tracing Capability on a PC,  picture

Atlas DCA75 Semiconductor Tester with Curve Tracing Capability on a PC,

$188.95



Thermoelectric Peltier Refrigeration Cooler Cooling Fan Semiconductor Radiator  picture

Thermoelectric Peltier Refrigeration Cooler Cooling Fan Semiconductor Radiator

$34.83



Peak, Atlas DCA55 Semiconductor Tester,  picture

Peak, Atlas DCA55 Semiconductor Tester,

$97.99



Dual Range Transistor Diode Semiconductor & Passive Curve Tracer Tester/Tracker picture

Dual Range Transistor Diode Semiconductor & Passive Curve Tracer Tester/Tracker

$26.99



Lab-Volt 91005-20 Semiconductor Devices circuit boards picture

Lab-Volt 91005-20 Semiconductor Devices circuit boards

$89.99



P266A Amp-Trap Form 101 Semiconductor Protection Fuse Block, 101-600A, 1 Pole picture

P266A Amp-Trap Form 101 Semiconductor Protection Fuse Block, 101-600A, 1 Pole

$167.93







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