Thursday, September 19, 2013

Can't see components in JScrollPane

Can't see components in JScrollPane

I'm using a JScrollPane to hold a JTextArea for a large area of text. I
add the TextArea directly to the JFrame, it works fine. But I add it to
the scrollpane and add the scrollpane, I don't see the textarea. Here's my
SSCCE:
public class foo extends JFrame{
//gui elements
JTextArea chatMonitor = new JTextArea();
JScrollPane textPane = new JScrollPane();
ChatFrame(final String nickname, final String login, final String server,
final String channel){
setSize(500,500);
chatMonitor.setEditable(false);
chatMonitor.setVisible(true);
textPane.add(chatMonitor);
textPane.setAutoscrolls(true);
textPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
textPane.setVisible(true);
add(textPane);
}
}

No comments:

Post a Comment