I am developing s60 using j2me with LWUIT in Eclipse.
I am writing this method to draw list item and try to create List manually rather than using Lwuit list. Because as i posted in my last question here is LinK.. don't know why but it decreases performance.
So In below method i trying to create in which i'm adding adding two labels to layoutX Container and adding that Conatiner to layoutY Container and Adding that layoutY to BaseContainer so output is looks like list.
Method is here ...
private void drawAgendasListItem(Vector vector) {
Container containerX[] = new Container[vector.size()];
Container containerY[] = new Container[vector.size()];
if (featuredeventsForm.contains(baseContainer)) {
baseContainer.removeAll();
featuredeventsForm.removeComponent(baseContainer);
System.out.println("base Container is removed ");
}
BoxLayout layoutX = new BoxLayout(BoxLayout.X_AXIS);
BoxLayout layoutY = new BoxLayout(BoxLayout.Y_AXIS);
for (int i = 0; i < vector.size(); i++) {
try {
containerX[i].setLayout(layoutX);
containerY[i].setLayout(layoutY);
Label startTime = new Label();
Label description = new Label();
startTime.getStyle().setBgTransparency(0);
startTime.setText("start 10:20 Am");
startTime.getStyle().setMargin(0, 0, 0, 5);
description.getStyle().setBgTransparency(0);
description.setText("decriptionString");
containerX[i].getStyle().setPadding(0, 0, 2, 2);
containerX[i].addComponent(startTime);
containerX[i].addComponent(description);
containerY[i].addComponent(containerX[i]);
baseContainer.addComponent(i, containerX[i]);
System.out.println("Component added to base Container @ " + i);
} catch (Exception e) {
System.out.println("Exception in drawAgendaListItem " + e);
}
}
featuredeventsForm.addComponent(baseContainer);
featuredeventsForm.invalidate();
featuredeventsForm.repaint();
System.out.println("All elements added and form repainted");
}
In above method when i try to assign layout to Container it fires an NullPointerException at line
containerX[i].setLayout(layoutX);
.
I don't understand why it's happening, I was also try to comment that lines then it fires NullPointerException at line containerX[i].getStyle().setPadding(0, 0, 2, 2);
.
please help ....