我所说的 JLabel-JTextField 对是指 JLabel 组件后跟 JTextField 组件,例如“参数 1:-----”,其中“-----”表示空白 JTextField。
问题是,JLabels 的宽度由于参数名称长度的不同而变化,因此 JTextFields 的开头不是垂直对齐的。
有什么方法可以将 JLabels 垂直向右对齐,以便后续 JTextField 的开头对齐吗?谢谢。
最佳答案
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:
使用将文本推送到 RHS 的标签对齐方式。
<小时/>另请参阅this answer对于 MCVE。
关于java - 如何垂直对齐 JLabel-JTextField 对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48991526/