按钮 lWUIT j2me setlocation

发布于 2024-11-19 04:33:05 字数 433 浏览 3 评论 0原文

如何在 LWUIT 中设置按钮位置?

   public void error()
  {
      error = new Dialog();
      e = new Label("EMPTY FIELDS!!!");
      t= new TextArea("You Can't Leave The Fields Empty...",8,13);
      error.addComponent(e);
      error.addComponent(t);
      eok = new Button("Ok");
      eok.setAlignment(Component.CENTER);
      eok.addActionListener(this);
      error.addComponent(eok);
      error.show();
  }

How can i set the Button location in LWUIT??

   public void error()
  {
      error = new Dialog();
      e = new Label("EMPTY FIELDS!!!");
      t= new TextArea("You Can't Leave The Fields Empty...",8,13);
      error.addComponent(e);
      error.addComponent(t);
      eok = new Button("Ok");
      eok.setAlignment(Component.CENTER);
      eok.addActionListener(this);
      error.addComponent(eok);
      error.show();
  }

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

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

发布评论

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

评论(1

維他命╮ 2024-11-26 04:33:05

您需要使用布局管理器。我猜您正在尝试将按钮居中,而不仅仅是将其与中心对齐,只需将其添加到具有中心流布局的容器中即可:

Container c = new Container(new FlowLayout(Component.CENTER));
c.addComponent(btn);

You need to use a layout manager. I'm guessing you are trying to center a button and not just align it to the center, just add it to a container with a center flow layout:

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