Simple JTextArea in JScrollPane problem
Hello everybody,
I think I have a very simple problem, anyway I don't seem to realize what I'm doing wrong.
I want to have a window 400x400 px. Within the complete window there is a scrollable Textarea.
I tried to solve it like this
JFrame frame =new JFrame("ScrollPaneTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel =new JPanel();
panel.setLayout(new BorderLayout());
JScrollPane scrollPane =new JScrollPane();
JTextArea textArea =new JTextArea();
textArea.setText("Test");
textArea.setBackground(Color.blue);
scrollPane.add(textArea);
scrollPane.validate();
panel.add(scrollPane, BorderLayout.CENTER);
panel.validate();
frame.getContentPane().add(panel);
frame.getContentPane().validate();
frame.setSize(400, 400);
frame.setVisible(true);
I expect to screen to be blue and having test written in it. But it seems like there is nothing in it all.
When I fo frame.pack() the window gets small, just the title bar stays.
Do you know what I'm doing wrong?
Thank you very much,
Stefan

