如何将组件放置在另一个组件的前面?

发布于 2024-12-25 09:44:39 字数 155 浏览 1 评论 0原文

我想将组件 A 和 B 放置在带有 List 的组件上。我需要列表文本可见。我找不到哪个布局可以做到这一点。 lwuit 中的这种行为如何?存在哪些解决方案?

在此处输入图像描述

I want to place the components A and B over component with List. I need that would text of list will be to visible. I can not find which layout can do it.
How this behavior is in lwuit? What solutions exist?

enter image description here

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

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

发布评论

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

评论(2

若沐 2025-01-01 09:44:39

问题有点不清楚,如果您希望组件的 A 和 B 位于屏幕底部并且列表滚动到上方,则 jmunoz 的答案是正确的。然而,从图中看来,您似乎想要一种“始终在顶部”的效果,您可以通过玻璃窗格(对于非交互式组件)或通过 LayeredLayout 类来实现。

使用以下命令实际上非常简单:

myForm.setLayout(new LayeredLayout());
myForm.setScrollable(false);

// will occupy the entire area of the form but should be scrollable
myForm.addComponent(componentUnderneath);
Container south = new Container(new BorderLayout());
myForm.addComponent(south);
south.addComponent(BorderLayout.SOUTH, whateverYouWantToPlaceOnTopInTheSouth);

The question is somewhat unclear, jmunoz answer is correct if you want component's A and B to reside at the bottom of the screen and the list to scroll above. However from the drawing it seems you want an "always on top" effect which you can achieve either via a glass pane (for non-interactive components) or via the LayeredLayout class.

This is actually quite simple using the following:

myForm.setLayout(new LayeredLayout());
myForm.setScrollable(false);

// will occupy the entire area of the form but should be scrollable
myForm.addComponent(componentUnderneath);
Container south = new Container(new BorderLayout());
myForm.addComponent(south);
south.addComponent(BorderLayout.SOUTH, whateverYouWantToPlaceOnTopInTheSouth);
怀里藏娇 2025-01-01 09:44:39

您必须执行以下操作:

Form 不得滚动。使用Form.setScrollable(false)。将“Form”的布局设置为 BORDER_LAYOUTmyForm.setLayout(new BorderLayout()) 。好的,在 BorderLayout 中,您可以根据需要将组件放入 Form 中。

List 组件放在 BorderLayout 的中心,用 myForm.addComponent(BorderLayout.CENTER, List) 将另外两个元素放在南边使用此布局,

Container southContainer = new Container();
southContainer.addComponent(A);
southContainer.addComponent(B);
myForm.addComponent(BorderLayout.SOUTH, southContainer)

您可以获得一个可滚动的列表和两个始终可见的元素。

You must do the following:

The Form must not do scroll. Use Form.setScrollable(false). Set the layout of the ´Form´ to BORDER_LAYOUT, myForm.setLayout(new BorderLayout()) . Ok in BorderLayoutyou can put the components in the Form as you want.

Put the Listcomponent in the center of the BorderLayout with myForm.addComponent(BorderLayout.CENTER, List) and the other two elements in the south of the layout using

Container southContainer = new Container();
southContainer.addComponent(A);
southContainer.addComponent(B);
myForm.addComponent(BorderLayout.SOUTH, southContainer)

With this you can get a scrollable Listand two elements always visible.

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