How to align JLabel-JTextField pairs vertically

前端 未结 7 1161
独厮守ぢ
独厮守ぢ 2020-12-11 02:33

What I mean by a JLabel-JTextField pair is a JLabel component followed by a JTextField one, for example, \"Parameter 1: -----\" where \"-----\" denotes a blank JTextField.

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-11 03:26

    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. E.G. from the JavaDocs:

    enter image description here

    Use the label alignment that pushes the text to the RHS.


    See also this answer for an MCVE.

提交回复
热议问题