Search code examples
java-melwuit

J2ME LWUIT - Error showing outside screen labels on scroll


I'm working on a J2ME application using LWUIT. I need to show 10 values with a Label each one.

Something like this:

Label1       Value1
Label2       Value2
Label3       Value3
Label4       Value4
............
LabelN       ValueN

I'm using 1 Container for each "row" and one big Container for each "row container"

My problem is with the "rows" outside the screen. The last 4 pairs of Label+value are not showing when I use the scroll

I don't know why. Can someone solve this?

This is my code:

this.setLayout(new BorderLayout());
PromotionMonitorDTO promotionMonitorDTO = Cloud.getPromotionMonitor();
Utils utils = new Utils();
Font f = Font.getBitmapFont("movSmall");
Container cellContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
Container rowContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));

//FIRST PAIR///////////////////////

String stringValue = utils.calendarToShorString(promotionMonitorDTO.getLastUpdate());
Label valor = new Label(LanguageManager.getText("LastUpdate"));
valor.getStyle().setFont(f);        
rowContainer.addComponent(valor);  
valor = new Label(LanguageManager.getText(stringValue));
valor.getStyle().setFont(f);
rowContainer.addComponent(valor);        
cellContainer.addComponent(rowContainer);
rowContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));

//SECOND PAIR///////////////////////

stringValue = String.valueOf(promotionMonitorDTO.getInitialTarget());
valor = new Label(LanguageManager.getText("InitialTarget"));
valor.getStyle().setFont(f);        
rowContainer.addComponent(valor);  
valor = new Label(LanguageManager.getText(stringValue));
valor.getStyle().setFont(f);
rowContainer.addComponent(valor);   
cellContainer.addComponent(rowContainer);

////////8 MORE PAIRS////////////////////

this.addComponent(BorderLayout.NORTH, cellContainer);

Solution

  • Finally I solved.

    I removed the second Container, I changed the Layout of the form to BoxLayout(BoxLayout.Y_AXIS) and I added all the "row containers" to the form,

    With those changes, I have the same Graphic funcionality and the scroll is working.

    I have to remove the question? o leave it for others?