This is my code for text field. It is not changing the line when the line ends, but continues to go on, making the frame look weird.
I tried to use a scroll pane, but it did not help me.
JTextArea TextArea = new JTextArea(7,10);
gridConstraints.gridx = 0;
gridConstraints.gridy = 0;
TextPanel.add(TextArea, gridConstraints);
TextArea.setEditable(true);
Without line & word wrapping, the size of a JTextArea
will grow beyond its original size. You could call:
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
Side notes:
JTextArea
are typically placed in JScollPane
containers to facilitate scrolling.TextArea
textArea