Java 在两个容器之间创建一条空行
我想在表单中嵌入的容器之间创建一个空行 具有方形布局Y_轴 下面的部分只显示了“test1 test”,但我希望 “测试1 测试2“ 甚至更多的线Java 在两个容器之间创建一条空行,java,java-me,lwuit,Java,Java Me,Lwuit,我想在表单中嵌入的容器之间创建一个空行 具有方形布局Y_轴 下面的部分只显示了“test1 test”,但我希望 “测试1 测试2“ 甚至更多的线 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 e
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) {
}
}
在容器之间添加
新标签(“”
可以在标签中提供图像在容器之间添加新标签(“”
可以在标签中提供图像可以使用样式对象设置第一个标签的边距,如下所示:
Label textLabel = new Label("test1");
Style style = textLabel.getStyle();
style.setMargin(Component.BOTTOM,40);
current.addComponent(textLabel);
可以使用样式对象设置第一个标签的边距,如下所示:
Label textLabel = new Label("test1");
Style style = textLabel.getStyle();
style.setMargin(Component.BOTTOM,40);
current.addComponent(textLabel);
插入图像可能不是正确的方法<代码>当前.addComponent(新标签(“test1”);mainContainer.addComponent(当前);当前=新容器();当前.addComponent(新标签(“”);当前。setPreferredH(40);mainContainer.addComponent(当前);f.添加组件(主容器);当前=新容器();当前.addComponent(新标签(“test2”));mainContainer.addComponent(当前)代码>不起作用-插入图像听起来是错误的。插入图像可能不是正确的方法<代码>当前.addComponent(新标签(“test1”);mainContainer.addComponent(当前);当前=新容器();当前.addComponent(新标签(“”);当前。setPreferredH(40);mainContainer.addComponent(当前);f.添加组件(主容器);当前=新容器();当前.addComponent(新标签(“test2”));mainContainer.addComponent(当前)代码>不行-插入图像听起来是错误的。哦,天哪,谢谢你-我已经在手动修改页边距了,但是我太专注于“创建新行”,以至于我没有看到它。看起来我很快就回答了<代码>当前=新容器();标签文本标签=新标签(“测试1”);Style Style=textlab.getStyle();样式设置边距(组件顶部,40);current.addComponent(文本标签);mainContainer.addComponent(当前);f.添加组件(主容器);当前=新容器();当前.addComponent(新标签(“test2”));mainContainer.addComponent(当前)代码>顶部和底部都不是我所需要的-如果我不做一些左边距或右边距,也不是“真正的新行”,布局仍然是并排排列的。是的,它是设置边距,需要在mainContainer上设置布局,而不是在表单上!哦,我的天,谢谢你-我已经在手动修改页边距,但我太专注于“创建新行”,以至于我没有看到它。似乎我很快就回答了<代码>当前=新容器();标签文本标签=新标签(“测试1”);Style Style=textlab.getStyle();样式设置边距(组件顶部,40);current.addComponent(文本标签);mainContainer.addComponent(当前);f.添加组件(主容器);当前=新容器();当前.addComponent(新标签(“test2”));mainContainer.addComponent(当前)代码>顶部和底部都不是我所需要的-如果我不做一些左边距或右边距,也不是“真正的新行”,布局仍然是并排排列的。是的,它是设置边距,需要在mainContainer上设置布局,而不是在表单上!让我们换个说法:form.append(“test”);格式。追加(“\n”);附加表格(“测试2”);如何将此LCDUI代码转换为LWUIT?现已修复-重要的是要在主容器上而不是表单上添加布局!然后正确地执行它:
Container curLine=newcontainer();curLine.setPreferredH(someFontYouAreUsing.getHeight());mainContainer.addComponent(卷线)代码>让我们换个说法:form.append(“test”);格式。追加(“\n”);附加表格(“测试2”);如何将此LCDUI代码转换为LWUIT?现已修复-重要的是要在主容器上而不是表单上添加布局!然后正确地执行它:Container curLine=newcontainer();curLine.setPreferredH(someFontYouAreUsing.getHeight());mainContainer.addComponent(卷线)代码>