Here is just a small SSCCE:
import java.awt.*;
import javax.swing.*;
public class TextAreaInScrollpane
{
static JPanel mPanel = new JPanel();
static JScrollPane mScrollPane;
public static void main(String[] args)
{
mPanel = new JPanel(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.anchor = GridBagConstraints.NORTHWEST;
constraints.fill = GridBagConstraints.BOTH;
constraints.weightx = 1.0;
constraints.weighty = 1.0;
mScrollPane = new JScrollPane(mPanel);
JTextArea ta = new SpecialTextArea();
ta.setLineWrap(true);
ta.setText("Hallo, mein Name is Theodor. Hallo, mein Name is
Theodor. Hallo, mein Name is Theodor. Hallo, mein Name is Theodor.
Hallo, mein Name is Theodor. Hallo, mein Name is Theodor. Hallo, mein
Name is Theodor. Hallo, mein Name is Theodor. Hallo, mein Name is
Theodor. Hallo, mein Name is Theodor. Hallo, mein Name is Theodor. ");
mPanel.add(ta, constraints);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
frame.setContentPane( mScrollPane );
frame.pack();
frame.setVisible(true);
}
@SuppressWarnings("serial")
private static class SpecialTextArea extends JTextArea
{
public SpecialTextArea()
{
super("");
super.setEditable(false);
super.setLineWrap(true);
super.setWrapStyleWord(true);
}
public Dimension getMinimumSize()
{
return new Dimension(1,1);
}
}
}
Hello,
i got the problem described in the quote below but the suggested
solution (overriding getMinimumSize()) doesn't work for me.