package Rainbow;
import javax.swing.*;
import java.awt.*;
public class Entry
{
public static void main(String[] Q)
{
JFrame R = new JFrame();
JPanel P = new JPanel()
{
public Dimension getMaximumSize()
{ return new Dimension(Integer.MAX_VALUE,getMinimumSize().height); }
};
P.setLayout(new BoxLayout(P,BoxLayout.Y_AXIS));
JTextArea A = new JTextArea(
"VERYLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONGLONG");
A.setEditable(false);
A.setLineWrap(true);
P.add(new Label("Text"));
P.add(A);
JScrollPane S = new JScrollPane(P);
R.add(S);
R.setSize(300,300);
R.setLocationRelativeTo(null);
R.setVisible(true);
}
}
It is how it looks on startup. StartUp
After reducing the Frame's size. Reduce The JTextArea inside would not reduce its size.
I'm using JTextArea here because it seems to be the easiest way to do line wrap on a component. So how to solve it? Or is there an alternate way to do the same thing?