How to align JLabel-JTextField pairs vertically

前端 未结 7 1120
独厮守ぢ
独厮守ぢ 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:32

    This is a perfect use case for DesignGridLayout:

    DesignGridLayout layout = new DesignGridLayout(contentPane);
    layout.labelAlignment(LabelAlignment.RIGHT);
    layout.row().grid(label1).add(field1);
    layout.row().grid(label2).add(field2);
    ...
    
    0 讨论(0)
提交回复
热议问题