gpt4 book ai didi

java - 如何垂直对齐 JLabel-JTextField 对

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:09:03 25 4
gpt4 key购买 nike

我所说的 JLabel-JTextField 对是指一个 JLabel 组件后跟一个 JTextField 组件,例如,“参数 1:-----”,其中“-----”表示空白 JTextField。

问题是,JLabels 的宽度因参数名称的长度不同而不同,因此 JTextFields 的开头未垂直对齐。

有什么方法可以将 JLabel 垂直对齐到它们的右侧,以便对齐后面的 JTextFields 的开头吗?谢谢。

最佳答案

Is there any way to align the JLabels vertically to their right, so that the starts of JTextFields that follow would be aligned?

1.6+, GroupLayout .例如。来自 JavaDocs:

enter image description here

使用将文本推送到 RHS 的标签对齐方式。


另见 this answer对于 MCVE。

关于java - 如何垂直对齐 JLabel-JTextField 对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6005258/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com