Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4250125

Graphics.drawline() hangs for some values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.2.2, 1.3.0
    • client-libs
    • 2d
    • generic, x86
    • generic, windows_nt



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

            flar Jim Graham
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: