Line wrap in a JTextArea causes JScrollPane to missbehave with MiGLayout

前端 未结 4 2011
轻奢々
轻奢々 2021-02-10 01:58

I am having trouble with the same thing as this guy:

MigLayout JTextArea is not shrinking when used with linewrap=true

and I used the solution described in one o

4条回答
  •  生来不讨喜
    2021-02-10 02:31

    Not really sure what you're trying to achieve here, try running this and see if it fits your need?

    
    public class MiGTest2 extends JFrame {
        public MiGTest2() {
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
            JPanel panel = new JPanel(new MigLayout("fillx, debug", "[fill]"));
    
            JTextArea textArea = new JTextArea();
            textArea.setLineWrap(true);
            panel.add(new JScrollPane(textArea), "wmin 10, grow, push");
    
            setLayout(new MigLayout("fill"));
    
            JScrollPane scrollPane = new JScrollPane(panel);
            add(scrollPane, "grow, push");
    
            pack();
        }
    
        public static void main(String[] args) {
            new MiGTest2().setVisible(true);
        }
    }
    
    

提交回复
热议问题