Reputation: 959
I have the following code: the problem is that when i run the application, the JPanel containing those components stretches because of setLineWrap(true) I've inserted the JTextArea in a JScrollPane as suggested here http://docs.oracle.com/javase/tutorial/uiswing/components/textarea.html but with no result
titolo=new JLabel("title");
text=new JTextArea("");
scrollPane = new JScrollPane(text);
text.setLineWrap(true);
griglia=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(griglia);
buildConstraints(gbc,0,0,1,1,100,1);
griglia.setConstraints(titolo,gbc);
buildConstraints(gbc,0,1,1,1,100,100);
griglia.setConstraints(scrollPane,gbc);
add(titolo);
add(scrollPane);
Upvotes: 0
Views: 90
Reputation: 4637
Check GridBagConstraint here in the fill - The initial fill value use GridBagConstraints.NONE.
Upvotes: 1