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

Graphics.setClip() throws IllegalArgumentException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.0
    • docs
    • None
    • sparc
    • solaris_7



      Name: atR10191 Date: 11/26/2001


      specification for method
      public abstract void setClip(Shape clip)
      of class java.awt.Graphics does not state that the method can throw an
      exception. But in case of PBP-b13 and PP-b39 the method throws an
      IllegalArgumentException being passed a Polygon object
      ============ Test37.java ==============================================
      import java.awt.*;

      public class Test37 {
          public static void main(String[] args) {

              Frame frm = new Frame();
              frm.show();
              Graphics g = frm.getGraphics();

              int[] xpoints = {0,-10,0,10};
              int[] ypoints = {0,10,20,10};
          
              int x, y, width, height;
          
              g.setClip(new Polygon(xpoints,ypoints,xpoints.length));

              System.out.println("OKAY");
              System.exit(0);
          }
      }
      ======== end of Test37.java ==========================================
      ======== Output under pbp RI build b13 and pp b39 ====================
      java.lang.IllegalArgumentException: setClip(Shape) only supports Rectangle objec
      ts
              at sun.awt.gtk.GdkGraphics.setClip(Ljava/awt/Shape;)V(Unknown Source)
              at Test37.main([Ljava/lang/String;)V(Unknown Source)
      ======== End of output under pbp RI build b13 and pp b39 =============
      ======== Output under jdk 1.4===============================
      OKAY
      ======== End of output under jdk 1.4========================
      ======================================================================

            duke J. Duke
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: