I have been trying to make a JTextArea which I can write in like one would in a Word Document; it wraps around when the texts gets too wide, and scrolls down when it gets too high).
So far, the wrap when it gets too wide works just fine. However, the scroll bar does not work. It does show up, but it does not ever get any longer which means that anything outside of the original dimensions of the JTextArea cannot be viewed no matter what.
Does anyone know what I am doing wrong? Here's how the code looks like; it is the JPanel named panel which I am using later on by adding it to another JPanel which in turn is added to a JFrame.
JTextArea text = new JTextArea(rows, columns);
text.setLineWrap(true);
text.setWrapStyleWord(true);
text.setPreferredSize(new Dimension(text.getWidth(), text.getHeight()));
JScrollPane scroll = new JScrollPane(text);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
panel.add(scroll);
Worked fine, when I deleted -
text.setPreferredSize