英文:
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"));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论