MigLayout JTextArea is not shrinking when used with linewrap=true

后端 未结 2 716
青春惊慌失措
青春惊慌失措 2020-12-10 14:36

If I use a JTextArea with MigLayout like this:

MigLayout thisLayout = new MigLayout(\"\", \"[][grow]\", \"[]20[]\");
   this.setLayout(thisLayout);
   {
jLab         


        
2条回答
  •  粉色の甜心
    2020-12-10 15:12

    I just discovered that this can simply be resolved by changing the line

    this.add(jTextArea1, "cell 0 1 2 1,growx");
    

    to

    this.add(jTextArea1, "cell 0 1 2 1,growx, wmin 10");
    

    and no extra panels are needed. Setting an explicit minimum size is what does the trick.

    Explanation: see the note under the section on padding in the MiGLayout whitepaper:

    http://www.migcalendar.com/miglayout/whitepaper.html

提交回复
热议问题