如何将组件放置在屏幕底部

发布于 2024-12-17 19:39:16 字数 416 浏览 4 评论 0原文

super();
this.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
this.addComponent(new TopBar());
this.addComponent(new MyList());
this.addComponent(new BottomBar()); // must be below

我尝试使用 BorderLayout,但它没有帮助我。

在此处输入图像描述

myList 并不总是占据整个屏幕。但它始终位于 mylist 下。

抱歉,我的问题很简单,我还是初学者。

super();
this.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
this.addComponent(new TopBar());
this.addComponent(new MyList());
this.addComponent(new BottomBar()); // must be below

I tried to use BorderLayout, but it didn't help me.

enter image description here

myList is not always occupy the all screen. But it is always located under mylist.

Sorry for simple question, I'm still beginner lwuit.

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

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

发布评论

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

评论(1

司马昭之心 2024-12-24 19:39:16

我认为您可能没有将布局设置为适当的容器,请尝试下面的代码,看看它是否适合您的要求。

    Button topBar = new Button("TopBar");
    List mylist = new List(new String[]{"Item 1","Item 2","Item 3"});
    Button bottomBar = new Button("BottomBar");

    Form form = new Form();
    Container contentPane = form.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.addComponent(BorderLayout.NORTH, topBar);
    contentPane.addComponent(BorderLayout.CENTER, mylist);
    contentPane.addComponent(BorderLayout.SOUTH, bottomBar);
    contentPane.revalidate();

    form.show();

上面的代码你可以与Container互换使用。

PS:为了运行上述代码,请确保在代码中正确设置资源和主题。如果您需要这方面的帮助,请检查下载的 LWUIT 库 zip 文件中包含的 LWUITDemo jar 文件/项目。

I think you might not be setting the layout to appropriate container, try below code see if it suits your requirement.

    Button topBar = new Button("TopBar");
    List mylist = new List(new String[]{"Item 1","Item 2","Item 3"});
    Button bottomBar = new Button("BottomBar");

    Form form = new Form();
    Container contentPane = form.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.addComponent(BorderLayout.NORTH, topBar);
    contentPane.addComponent(BorderLayout.CENTER, mylist);
    contentPane.addComponent(BorderLayout.SOUTH, bottomBar);
    contentPane.revalidate();

    form.show();

The above code you can interchangeably use it with Container.

PS: In order to run the above code make sure you set the Resources and Theme correct in your code. If you need help on this check the LWUITDemo jar file / project that is included in the downloaded LWUIT library zip file.

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