简体   繁体   English

布局标签从左到右

[英]Layout labels from left to right

I would like some help on choosing or creating a layout for a component to which I will add labels at runtime. 我想帮助选择或创建一个组件的布局,我将在运行时添加标签。 For example the component size will be 400*50 and empty when the application start up. 例如,组件大小将为400 * 50,并在应用程序启动时为空。 Then some action will add a first label at position 0, the second at position first label's width, the third at first label's width + second label's width and so on. 然后一些动作将在位置0添加第一个标签,第二个位于第一个标签的宽度,第三个在第一个标签的宽度+第二个标签的宽度,依此类推。 A bit like the FlowLayout except that I want my labels to start at the left of the container and not in the center. 有点像FlowLayout除了我希望我的标签从容器的左边开始而不是在中心。 Thanks for helping. 谢谢你的帮助。

Just use a FlowLayout and call setAlignment(FlowLayout.LEFT); 只需使用FlowLayout并调用setAlignment(FlowLayout.LEFT); (or use one of the constructors that takes an alignment code). (或使用带有对齐代码的构造函数之一)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM