为什么在TextArea中写文本是不可能的?

时间:2012-02-02 08:37:50

标签: java-me lwuit lwuit-textarea

TextField内有ListBoxTextAreaFormTextArea是最后一项。通过手机的导航按键导航项目时,我无法在cursor中看到blinking TextArea,我无法撰写文字!虽然我知道cursor位于TextArea范围内,因为前两个项目中没有blinking focus。这是代码:

public class CompteRendu extends Form implements FocusListener, DataChangedListener {
    private Container x1 = new Container(new BoxLayout(BoxLayout.X_AXIS));
    private Container x2 = new Container(new BoxLayout(BoxLayout.X_AXIS));
    private Container x3 = new Container(new BoxLayout(BoxLayout.X_AXIS));
    private Container x4 = new Container(new BoxLayout(BoxLayout.X_AXIS));
    private Container x5 = new Container(new BoxLayout(BoxLayout.X_AXIS));
    private Container CntnrYforAll = new Container(new BoxLayout(BoxLayout.Y_AXIS));
    private Label dateL, lieuL, dossier, client, resultat;
    private Label dateData, dossierData, clientData;
    private TextField lieu;
    private int nbVKBshow;
    private ListBox resultatList;
    private TextArea compteRendu;
    public CompteRendu(boolean general)
    {
        super();
        if (general)
            setTitle("Compte rendu général");
        dateL       = new FicheLibelle("Date");
        lieuL       = new FicheLibelle("Lieu");
        dossier     = new FicheLibelle("Dossier");
        client      = new FicheLibelle("Client");
        resultat    = new FicheLibelle("Résultat");
        dateL.setPreferredW(Comparator.max(new int[]{dateL.getPreferredW(),lieuL.getPreferredW(),dossier.getPreferredW(),client.getPreferredW(),resultat.getPreferredW()}));
        lieuL.setPreferredW(Comparator.max(new int[]{dateL.getPreferredW(),lieuL.getPreferredW(),dossier.getPreferredW(),client.getPreferredW(),resultat.getPreferredW()}));
        dossier.setPreferredW(Comparator.max(new int[]{dateL.getPreferredW(),lieuL.getPreferredW(),dossier.getPreferredW(),client.getPreferredW(),resultat.getPreferredW()}));
        client.setPreferredW(Comparator.max(new int[]{dateL.getPreferredW(),lieuL.getPreferredW(),dossier.getPreferredW(),client.getPreferredW(),resultat.getPreferredW()}));
        resultat.setPreferredW(Comparator.max(new int[]{dateL.getPreferredW(),lieuL.getPreferredW(),dossier.getPreferredW(),client.getPreferredW(),resultat.getPreferredW()}));
        dateData    = new Label(Formatage.dateToStringHH24(new Date()));
        dossierData = new Label();
        clientData  = new Label();
        lieu        = new ChpModif(100, this, this, null);
        resultatList = new ListBox(new String[]{"Oui","Non"},lieu.getPreferredH(),getPreferredW(),getPreferredH(),lieu.getSelectedStyle().getMargin(Component.TOP),lieu.getSelectedStyle().getMargin(Component.BOTTOM));
        compteRendu = new TextArea(5, 100);
        compteRendu.setGrowByContent(true);
        compteRendu.setFocusable(true);
        compteRendu.setEditable(true);
        x1.addComponent(dateL);
        x1.addComponent(dateData);
        x2.addComponent(lieuL);
        x2.addComponent(lieu);
        if (!general)
        {

        }
        x5.addComponent(resultat);
        x5.addComponent(resultatList);
        CntnrYforAll.addComponent(x1);
        CntnrYforAll.addComponent(x2);
        if (!general)
        {

        }
        CntnrYforAll.addComponent(x5);
        CntnrYforAll.addComponent(compteRendu);
        setLayout(new FlowLayout(Component.CENTER));
        addComponent(CntnrYforAll);
    }

那么如何在导航到TextArea时使光标可见并允许写入文本?

1 个答案:

答案 0 :(得分:3)

你不能这样做。你必须使用LWUIT TextField。看看这个:

TextArea question

TextArea question