I have created a textarea, and i need a scrollbar applied to the textarea when necessary (when the text gets too long down and it cant be read anymore).
this is the code
You have to remove the code line that makes the JTextArea
have absolute size on the screen due to using setBounds()
. This makes it non-resizable, and JScrollPane
works only if its content is resizable.
// wrong
textArea.setBounds(10, 152, 456, 255);
Please read JTextArea and JScrollPane tutorial; please run examples from both tutorials.