1

如何将插图设置为 Vaadin 标签。我在下面开发了。我想在按钮和标签之间留一些空间。

        button_3 = new Button();
        button_3.setCaption("Button");
        button_3.setImmediate(true);
        button_3.setWidth("-1px");
        button_3.setHeight("-1px");
        horizontalLayout_4.addComponent(button_3);

        // prize_set_label
        prize_set_label = new Label();
        prize_set_label.setImmediate(false);
        prize_set_label.setWidth("-1px");
        prize_set_label.setHeight("-1px");
        prize_set_label.setValue("small:23");
        horizontalLayout_4.addComponent(prize_set_label);
4

2 回答 2

1

要在(大多数)布局中添加组件之间的间距,您可以使用 setSpacing(boolean) - 例如horizontalLayout_4.setSpacing(true);

如果你想改变间距的大小,你必须在 CSS 中改变它。

我不明白你用按钮和标签的大小在那里做什么;据我所知,将宽度/高度设置为负值在 Vaadin 中无效。

于 2013-05-30T07:29:48.017 回答
0

对于一些想要修改 Component 的人Insets(例如,为了CellEditor在某些 LaF 下干净、可读(是的,我在看你 Nimbus!)),插图实际上是来自 Component 的Border,所以你需要指定一个空边框或只需删除它Component.setBorder(null)

请注意,如果没有定义边框,则使用的是组件对等插图。

于 2022-02-02T10:43:16.513 回答