/*
Program to illustrate the border bug.
When the window is resized to make it narrower (left to right),
the right border does not redraw properly. When the window
is made shorter (top to bottom), the bottom border doesn't redraw
properly. This happens regardless of which of the four borders
I use to resize the window.
A similar problem is described in RFE 4037592, but this is
clearly a bug, not an RFE.
Another similar problem is described in Bug 4088352, but that
bug only applies to JScrollPane. This bug shows up even if we
don't use JScrollPane. Also, that bug is marked fixed.
Changing the JScrollPane and JTextArea to ScrollPane and TextArea
fixes the problem.
Changing the JFrame to Frame fixes the problem by failing to fill
the border area.
*/
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
//import com.sun.java.swing.*;
//import com.sun.java.swing.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class BorderBug extends JPanel
{
public static void main(String[] args)
{
JFrame mf = new JFrame("Border Bug")
{
public Insets getInsets()
{
final int inset = 15;
Insets old = super.getInsets();
return new Insets(
old.top + inset,
old.left + inset,
old.bottom + inset,
old.right + inset);
}
};
mf.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{
System.exit(0);
}
}
);
BorderBug theBug = new BorderBug();
Container contentPane = mf.getContentPane();
contentPane.add(theBug);
mf.setBounds(10, 10, 600, 200);
mf.show();
}
BorderBug()
{
super();
setLayout(new BorderLayout());
JScrollPane scroller = new JScrollPane();
JTextArea theText = new JTextArea();
theText.setLineWrap(true);
theText.setWrapStyleWord(true);
theText.setEditable(true);
// Replacing these two lines with the third doesn't help
scroller.getViewport().add(theText);
add (scroller, BorderLayout.CENTER);
// add (theText, BorderLayout.CENTER);
}
}