Dynamically resize textarea to fit content

后端 未结 3 1290
梦毁少年i
梦毁少年i 2021-01-27 03:00

Here is a textarea I have put in my program using netbeans. The first image shows what the textarea looks like when I run the program. The second image is show the textarea afte

3条回答
  •  野性不改
    2021-01-27 03:25

    Include the JTextArea inside a JScrollPane

    JTextArea textArea = new JTextArea();
    JScrollPane scrollArea = new JScrollPane(textArea);
    

    This will dynamically change the text area based on if scrolling is needed or not

提交回复
热议问题