JDK-4250125 : Graphics.drawline() hangs for some values
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.2,1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-06-28
  • Updated: 2001-03-24
  • Resolved: 2001-03-24
Related Reports
Duplicate :  
Duplicate :  
Description

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) 
======================================================================

Comments
WORK AROUND Name: vi73552 Date: 06/28/99 Don't use ridiculous coordinates when invoking the Graphics methods. ======================================================================
11-06-2004

EVALUATION This is a dup of 4376103. jim.graham@Eng 2001-03-23
23-03-2001