为什么无法在 TextArea 中写入文本?

发布于 2025-01-01 21:25:36 字数 3551 浏览 0 评论 0原文

我的 Form 中有一个 TextField 、一个 ListBox 和一个 TextAreaTextArea 是最后一项。通过手机的导航按钮导航项目时,我在 TextArea 中看不到光标 闪烁,并且无法写入文本!虽然我知道cursorTextArea内,因为前两项中没有闪烁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 时写入文本?

There are a TextField , a ListBox and a TextArea inside my Form. The TextArea is the last item. When navigating the items through the navigational button keys of the phone then I cannot see the cursor blinking in the TextArea and I cannot write text ! Although I know that the cursor is within the TextArea because there is no blinking focus in the two previous items. Here is the code :

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);
    }

So how to make cursor visible and permitting writing text when navigating into the TextArea ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池木 2025-01-08 21:25:36

你做不到。您必须使用 LWUIT TextField。看看这个:

TextArea 问题

文本区域问题

You can't do it. You have to use LWUIT TextField. Look at this:

TextArea question

TextArea question

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文