Lwuit 在两个容器之间创建一条空线

发布于 2024-11-19 04:12:03 字数 1030 浏览 5 评论 0原文

我想在表单中嵌入的容器之间创建一个空行 与 BoxLayout Y_Axis。

下面的片段仅显示“test1 test”,但我想要

“test1

test2”

甚至更多行。

import com.sun.lwuit.Container;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.layouts.BoxLayout;

public class Bug extends javax.microedition.midlet.MIDlet {




public void startApp() {

    Display.init(this);

    Container mainContainer = new Container();
    Container current = new Container();
    Form f = new Form();
    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    current.addComponent(new Label("test1"));
    mainContainer.addComponent(current);
    current = new Container();
    current.setPreferredH(40);
    mainContainer.addComponent(current);
    f.addComponent(mainContainer);
    current = new Container();
    current.addComponent(new Label("test2"));
    mainContainer.addComponent(current);

    f.show();
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
} 

I'd like to create an empty line between to containers embedded in my form
with BoxLayout Y_Axis.

The following piece only shows "test1 test", but I'd like to have

"test1

test2"

or even more lines..

import com.sun.lwuit.Container;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.layouts.BoxLayout;

public class Bug extends javax.microedition.midlet.MIDlet {




public void startApp() {

    Display.init(this);

    Container mainContainer = new Container();
    Container current = new Container();
    Form f = new Form();
    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    current.addComponent(new Label("test1"));
    mainContainer.addComponent(current);
    current = new Container();
    current.setPreferredH(40);
    mainContainer.addComponent(current);
    f.addComponent(mainContainer);
    current = new Container();
    current.addComponent(new Label("test2"));
    mainContainer.addComponent(current);

    f.show();
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
} 

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

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

发布评论

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

评论(2

温暖的光 2024-11-26 04:12:03

您可以使用样式对象设置第一个标签的边距,如下所示:


Label textLabel = new Label("test1");
Style style = textLabel.getStyle();
style.setMargin(Component.BOTTOM,40);
current.addComponent(textLabel);

You can use style object for setting margin for first label, like this:


Label textLabel = new Label("test1");
Style style = textLabel.getStyle();
style.setMargin(Component.BOTTOM,40);
current.addComponent(textLabel);
兲鉂ぱ嘚淚 2024-11-26 04:12:03

在容器之间添加 new Label("") 您可以在标签中提供图像

add new Label("") between container you can give image in Label

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