我有一个带有图标的标签,我试图在底部设置垂直对齐方式,但是它不起作用。是一个问题吗?
Form hi = new Form("Label");
hi.add(new Button("Upper Border"));
Label bottomLabel = new Label("Label Text Bottom");
bottomLabel.setIcon(theme.getImage("Orange Line.png"));
bottomLabel.setVerticalAlignment(Component.BOTTOM);
hi.add(bottomLabel);
hi.add(new Button("Bottom Border"));
hi.show();
已编辑
我不希望获得上图所示的确切布局。那只是我所需要的一个例子。我希望能够添加带有图标的标签,并将文本设置在底部。但是我不想使用Containers来做到这一点,因为我需要在底部添加几行包含Icon和文本的行。下面是我想学的一个例子:
您可以使用borderlayout在表格的底部设置标签,如以下代码所示。我更改了表单的布局并将标签设置在底部
Form hi = new Form("Label");
**hi.setLayout(new BorderLayout());**
hi.add(BorderLayout.NORTH,new Button("Upper Border"));
Label bottomLabel = new Label("Label Text Bottom");
bottomLabel.setIcon(theme.getImage("Orange Line.png"));
bottomLabel.setVerticalAlignment(Component.BOTTOM);
**hi.add(BorderLayout.SOUTH,bottomLabel);**
//hi.add(new Button("Bottom Border"));
hi.show();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句