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
onelord2002
Posts: 66
Registered: ‎09-14-2011
My Device: Simulator
Accepted Solution

LabelField after GaugeField is not showing

Hi,

I'm trying to add a LabelField - GaugeField - LabelField inside a HorizontalFieldManager.

The both labels are being added this i can confirm by the width occupied by the gauge.

But i cannot see the second label. it is as if it disappeared.

 

HorizontalFieldManager hfm = new HorizontalFieldManager();

LabelField lf1 = new LabelField("hi");
GaugeField gf = new GaugeField("" , 1 , 100 , 30 , GaugeField.NO_TEXT);
LabelField lf2 = new LabelField("bye");

hfm.add(lf1);
hfm.add(gf);
hfm.add(lf2);

add(hfm);

 so i tried adding gaugeField into another HorizontalFieldManager and then add it like this.

 

HorizontalFieldManager hfm = new HorizontalFieldManager();
HorizontalFieldManager hfm2 = new HorizontalFieldManager();

LabelField lf1 = new LabelField("hi");
GaugeField gf = new GaugeField("" , 1 , 100 , 30 , GaugeField.NO_TEXT);
LabelField lf2 = new LabelField("bye");

hfm2.add(gf);

hfm.add(lf1);
hfm.add(hfm2);
hfm.add(lf2);

add(hfm);

 but even this didnt helped. The second label is still invisible :Eek:

 

Can anyone help me here?

 

i'm using

 

Blackberry 9530-Verizon

OS version : 5.0.0.328

 

Thanks :Rolleyes:

Please use plain text.
Developer
onelord2002
Posts: 66
Registered: ‎09-14-2011
My Device: Simulator

Re: LabelField after GaugeField is not showing

I got the answer :smileyvery-happy:

 

Instead of creating second hosidontalFieldManager in the begining

i created it after i created objects of lf1 and lf2.

now i set the width of this hfm2 to

getPreferredWidth() - timeStart.getPreferredWidth() - timeEnd.getPreferredWidth() ,getPreferredHeight()

This will substract the width occupied by label from total width and set the gauge width to that remaining space.

 

HorizontalFieldManager hfm = new HorizontalFieldManager();

LabelField lf1 = new LabelField("hi");
GaugeField gf = new GaugeField("" , 1 , 100 , 30 , GaugeField.NO_TEXT);
LabelField lf2 = new LabelField("bye");

HorizontalFieldManager hfm2 = new HorizontalFieldManager(){
	public void sublayout(int maxWidth, int maxHeight) {
		super.sublayout(getPreferredWidth() - lf1.getPreferredWidth() - lf2.getPreferredWidth() ,getPreferredHeight());
		setExtent(getPreferredWidth() - lf1.getPreferredWidth() - lf2.getPreferredWidth() , getPreferredHeight());
	}
};
hfm2.add(gf);

hfm.add(lf1);
hfm.add(hfm2);
hfm.add(lf2);

add(hfm);

 

Please use plain text.
Developer
onelord2002
Posts: 66
Registered: ‎09-14-2011
My Device: Simulator

Re: LabelField after GaugeField is not showing

although i didnt understood why i have to do that.

since i'm using field manager the gauge width should be set automatically

but it seems like that gauge is occuping Display.getWidth() (whole screen).

 

can anyone explain why it is like that???

Please use plain text.