Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Bug on HorizontalFieldManager implementation for OS 6+?

I'm testing a very simple layout in my current project, and some labelfields were missing in OS 6.0 and 7.0, while displaying correctly on previous versions. This is my code:

package org.test.hfm;

import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.CheckboxField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;

public final class TestScreen extends MainScreen
{
    public TestScreen() {    
        setTitle("HorizontalFieldManager Test");
        populate();
    }
    
    private void populate(){
    	deleteAll();
    	LabelField lf = new LabelField("Here an HFM with a checkbox and a label must be displayed:");
    	Manager m = new HorizontalFieldManager(Manager.NO_HORIZONTAL_SCROLL | Manager.USE_ALL_WIDTH);
    	m.add(new LabelField("   "));
		m.add(new CheckboxField("", true));				
		m.add(new LabelField("this is the checkbox description and should be displayed"));
		
		// This simple layout doesn't work on OS 6 nor 7!!.
		
		add(lf);
		add(m);    
    }
}

 The labelfield after the checkbox doesn't display for OS 6 nor 7. I tracked down the problem to the HorizontalFieldManager after long time reading code (my project's interface is much more complex). Given that a simple HorizontalFieldManager is one of the basic layout components, If I were correct and this is a bug, I'd say that this is inadmissible after 7 releases of the OS, which theoretically are backwards compatible.

 

Do you think I'm doing something wrong?

 

Regards.

 


Contributor
Posts: 40
Registered: ‎10-10-2011
My Device: BB Curve&Bold
My Carrier: Airtel

Re: Bug on HorizontalFieldManager implementation for OS 6+?

Hi,

Use this code instead of your checkbox code.Now try this.My case its working fine.You override paint and layout method its working.

m.add(new CheckboxField("", true){
protected void layout(int width,int height) {
int _width=30;
int _height=45;
super.layout(_width, _height);
setExtent(_width, _height);
}
protected void drawFocus(Graphics _g, boolean _on)
{
paint(_g);
invalidate();
}
protected void paint(Graphics g) {
super.paint(g);
}
});

Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: Bug on HorizontalFieldManager implementation for OS 6+?

@kannapan88 Thanks, but I cannot hardcode width and height. In my app, both the checkbox and the combo have the same font, and the font size is configurable by the user.

 

I already patched this by using a custom table layout for the problematic OS versions, but anyway, I think I'm going to fill an issue in Jira.

Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: Bug on HorizontalFieldManager implementation for OS 6+?

There was already an issue created, it is JAVAAPI-1366. reported on August 2010 and still unresolved. I doubt very much that in the current state of affairs RIM is going to do anything about it, with 7.1 suffering from it too, and no more Java API in the future.

Developer
Posts: 179
Registered: ‎06-15-2011
My Device: Storm 9550
My Carrier: Vodaphone

Re: Bug on HorizontalFieldManager implementation for OS 6+?

Instead of sending "" to m.add(new CheckboxField("", true));    , can you send the string in next label?

Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: Bug on HorizontalFieldManager implementation for OS 6+?

What do you mean? The problem is that CheckboxField built-in label is shown before the check, but I need to show the label after it, that's why I add a Checkbox with an empty label and add a LabelField with the text to right. However, due to a bug in CheckboxField, it uses all the available width (as if USE_ALL_WIDTH were setted always in constructor), so no field to the right is shown.

The only workarounds are, to my understanding, create your own checkbox (it is not difficult using a custom image) or restricting the with the field can take by replacing the HorizontalFieldManager with a custom table layout with fixed width for each column.

Shame they don't know how to implement a simple checkbox properly.