In my GUI, I have a JSplitPane containing two JTextArea controls enclosed in a JScrollPane, all enclosed in a JFrame.
I am having problems with the scrollbar updating when the window is maximized. The scrollbar updates correctly when the window is minimized, but fails to appear when I try to create a new line in one of the text areas. It updates when I minimize the window, but I am trying to get the scroll bar to update when the window is maximized.
this.text = new JTextArea(15, 70);
this.text.getDocument().addDocumentListener(this);
this.text.setBorder(BorderFactory.createLineBorder(Color.BLACK));
this.text.setLineWrap(true);
//Create lines
JTextArea lines = new JTextArea(15, 2);
lines.setBorder(BorderFactory.createLineBorder(Color.BLACK));
int lineHeight = lines.getRows();
int i = 1;
while (i <= lineHeight + 1) {
lines.append(Integer.toString(i) + "\n");
i++;
}
lines.setEditable(false);
//Pack it all
JSplitPane combo = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, lines,
this.text);
combo.setResizeWeight(0d / 10d);
//Create scrolling area
JScrollPane scroller = new JScrollPane(combo);
scroller.setVerticalScrollBarPolicy(
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
I have some more code regarding a menu and putting everything into a frame if that is important. I believe I am using the default layout manager.