How to align JLabel to the left of the JPanel?

后端 未结 2 1759
伪装坚强ぢ
伪装坚强ぢ 2021-02-15 12:50

I want to align my JLabel to the left.

    String lText = \"mybook<         


        
2条回答
  •  别那么骄傲
    2021-02-15 13:16

    You might wish to set the JLabel's horizontalAlignment property. One way is via its constructor. Try:

    JLabel label = new JLabel(lText, SwingConstants.LEFT);
    

    This can also be done via the expected setter method:

    label.setHorizontalAlignment(SwingConstants.LEFT);
    

提交回复
热议问题