Hi,

I have started to learn lwuit for S40 and I immediately encountered this problem. I am using lwuit.Form as container for components. Calling getComponentCount on the form instance always gives 1.

Code:
import com.sun.lwuit.*;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.util.Resources;
import java.io.IOException;
import javax.microedition.midlet.MIDlet;

/**
 * @author rth
 */
public class Midlet extends MIDlet implements ActionListener {

    private Command exitCmd;
    private Form form1;
    private Form form2;
    private Button backTo1;
    
    private Label f1l1;
    private Label f1l2;
    private Label f1l3;
    
    public Midlet() {
        Display.init(this);
        
        Font font = null;
        try {
            Resources res = Resources.open("/myres.res");
            //UIManager.getInstance().setThemeProps(res.getTheme("Theme 1"));
            font = res.getFont("Font 1");
        } 
        catch (IOException ex) {
            ex.printStackTrace();
        }
        
        exitCmd = new Command("Exit");
        
        form1 = new Form("Page 1");
        form1.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); //vertical
        
        form1.addCommand(exitCmd);
        form1.addCommandListener(this);
        form1.setBackCommand(exitCmd);
        
        Button btn1 = new Button("to Page 2");
        form1.addComponent(btn1);
        
        this.f1l1 = new Label("from 1 - label 1");
        this.f1l2 = new Label("from 1 - label 2");
        this.f1l3 = new Label("from 1 - label 3");
        form1.addComponent(f1l1);
        form1.addComponent(f1l2);
        form1.addComponent(f1l3);
        
        form2 = new Form("Page 2");
        form2.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); //vertical
        
        backTo1 = new Button("to Page 1");
        form2.addComponent(backTo1);
        
        Container f2c2 = new Container();
        f2c2.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        for (int i=0; i<20; ++i) {
            Label l = new Label("This is long label #" + i + ", which should have tickering enabled.");
            l.setFocusable(true);
            l.setTickerEnabled(true);
            if (font != null)
                l.getStyle().setFont(font);
            f2c2.addComponent(l);
        }
        form2.addComponent(f2c2);
        
        btn1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                form2.show();
            }
        });
        backTo1.addActionListener(this);
        
        
        form1.setTransitionInAnimator(
                CommonTransitions.createSlide(
                    CommonTransitions.SLIDE_HORIZONTAL, true, 1000));
        
        /*form2.setTransitionInAnimator(
                CommonTransitions.createSlide(
                    CommonTransitions.SLIDE_HORIZONTAL, false, 1000));*/
        form1.setTransitionOutAnimator(
                CommonTransitions.createSlide(
                    CommonTransitions.SLIDE_HORIZONTAL, false, 1000));
        
    }
    public void startApp() {
        form1.show();
        
        //test
        System.out.println("form1 cc = " + this.form1.getComponentCount()); //always shows 1
        System.out.println("form2 cc = " + this.form1.getComponentCount()); //always shows 1
        
        System.out.println("f1l1 idx = " + this.form1.getComponentIndex(this.f1l1));
        System.out.println("f1l2 idx = " + this.form1.getComponentIndex(this.f1l2));
        System.out.println("f1l3 idx = " + this.form1.getComponentIndex(this.f1l3));
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }

    public void actionPerformed(ActionEvent ae) {
        if (ae.getCommand() == this.exitCmd) {
            notifyDestroyed();
        }
        else if (ae.getComponent() == this.backTo1) {
            this.form1.show();
        }
    }
}
... and output:
Code:
form1 cc = 1
form2 cc = 1
f1l1 idx = 1
f1l2 idx = 2
f1l3 idx = 3
IDE: NetBeans 7.1.1
SDK: latest (I hope) S40 2.0
lwuit: S40-with-themes.jar (also happens with S40-full-touch.jar)

Is that a bug? Or am I missing something?