Name: vi73552 Date: 06/28/99
Hi,
Here's the test program:
import java.awt.*;
import javax.swing.*;
public class TestGraphics_drawLine {
public static void main(String[] arg) {
if (arg.length != 2) {
System.out.println("usage: %PROMPT%>java TestGraphics_drawLine {int} {int}");
return;
}
int x = Integer.parseInt(arg[0]);
int y = Integer.parseInt(arg[1]);
JFrame frame = new JFrame("Test Graphics.drawLine()");
frame.setSize(256, 256);
TPanel panel = new TPanel();
panel.x = x;
panel.y = y;
frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.setVisible(true);
}
}
class TPanel extends JPanel {
int x, y;
int x0 = 128, y0 = 128;
TPanel() { setBackground(Color.black); }
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.green);
//
// THE DRAWLINE CALL
//
// g.setClip(getBounds()); doesn't eliminate the bug
g.drawLine(x0, y0, x, y);
}
}
The demo works fine for most reasonable input values
but hangs for some values. For example:
>java TestGraphics_drawLine -32703 -32703
works fine (but is a little slow), however
>java TestGraphics_drawLine -32704 -32704
goes into a tailspin.
(Review ID: 84879)
======================================================================