S
Sadalsud
I'm trying to extend JFrame so I can do some basic line drawing. In the example
below, only one red line is supposed to be drawn diagonally. The problem I am
having is that whenever I resize the Window, the previous red diagonal lines do
not disappear. However, if I switch to another application that obscures the
entire window and switch back, the desired behavior is observed. I'm running
Java 1.4.1 on Windows 98. Any help that can be offered in resolving this matter
would be greatly appreciated.
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class FooFrame extends JFrame
{
public static void main(String args[])
{
FooFrame f;
f = new FooFrame();
}
public FooFrame()
{
super("FooFrame");
setBackground(Color.black);
setResizable(true);
setSize(300, 300);
show();
}
public void paint(Graphics g)
{
Graphics2D g2;
Line2D line;
g2 = (Graphics2D)g;
g2.setPaint(Color.red);
line = new Line2D.Double(0, 0, getSize().width, getSize().height);
g2.draw(line);
}
}
below, only one red line is supposed to be drawn diagonally. The problem I am
having is that whenever I resize the Window, the previous red diagonal lines do
not disappear. However, if I switch to another application that obscures the
entire window and switch back, the desired behavior is observed. I'm running
Java 1.4.1 on Windows 98. Any help that can be offered in resolving this matter
would be greatly appreciated.
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class FooFrame extends JFrame
{
public static void main(String args[])
{
FooFrame f;
f = new FooFrame();
}
public FooFrame()
{
super("FooFrame");
setBackground(Color.black);
setResizable(true);
setSize(300, 300);
show();
}
public void paint(Graphics g)
{
Graphics2D g2;
Line2D line;
g2 = (Graphics2D)g;
g2.setPaint(Color.red);
line = new Line2D.Double(0, 0, getSize().width, getSize().height);
g2.draw(line);
}
}