把按钮放在左下角怎么做?(Vaadin)

huangapple go评论89阅读模式
英文:

How do i put the button in the bottom left? (vaadin)

问题

我已阅读了Vaadin文档,但没有找到有用的信息。我已经创建了2个按钮,目前它们在垂直和水平方向上都位于中间,但我想把它们放在左下角。我不太清楚怎么做,因为在StackOverflow上也没有找到有用的信息(我是初学者)。

我的老师告诉我尝试这样做:

this.setJustifyContentMode(FlexComponent.JustifyContentMode.END); // 水平方向上将内容放在底部左侧。
this.setDefaultHorizontalComponentAlignment(Alignment.END); // 垂直方向上将内容放在底部左侧。

然而,这仍然没有起作用。

英文:

Ive red the vaadin documentation but i didnt find anything useful. i have created 2 buttons and right now, theyre in the middle vertically and horizontally, but i wanna put them in the bottom left. I dont really know how cause i havnt find anything useful on stackoverflow neither. (im a beginner)

my teacher told me to try this:
this.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER); // Put content at the bottom left horizontally.
this.setDefaultHorizontalComponentAlignment(Alignment.CENTER); // Put content at the bottom left vertically.

this still didnt work tho.

答案1

得分: 2

你可能想把按钮放在布局内。您可以在最新的Vaadin版本文档和代码示例中找到:https://vaadin.com/docs/latest/components/vertical-layout#horizontal-alignment

它会看起来像这样:

VerticalLayout layout = new VerticalLayout();
layout.setAlignItems(FlexComponent.Alignment.END);
layout.add(new Button("Button 1"));
layout.add(new Button("Button 2"));
英文:

You're probably looking to place the buttons inside a layout. You can find the documentation and code sample for the latest Vaadin version here: https://vaadin.com/docs/latest/components/vertical-layout#horizontal-alignment

It'd look something like this:

VerticalLayout layout = new VerticalLayout();
layout.setAlignItems(FlexComponent.Alignment.END);
layout.add(new Button("Button 1"));
layout.add(new Button("Button 2"));

huangapple
  • 本文由 发表于 2023年8月10日 19:51:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76875496.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定