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

LabelView is incorrectly getting a FontRendererContext causing NPE

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 1.2.2
    • client-libs
    • generic, x86
    • generic, windows_nt

      On JDK1.2.2 LabelView is incorrectly trying to optain the FontRendererContext when it possibly doesn't exist. I get a NullPointerException when I try to resize the master view. In this case I have a container but it is a dummy container that hasn't been added to anything else. Can we at least get this fixed for the release after 1.2.2?


      line 1315

      if (container == null) {
      frc = DefaultRenderContext;
      }
      else {
      frc = ((Graphics2D)container.getGraphics()).
      -> getFontRenderContext();
      }
              

      Should be changed to

      Container container = getContainer();
      if (container == null) {
      frc = DefaultRenderContext;
      }
      else {
      Graphics2D g2d = (Graphics2D)container.getGraphics();
      if (g2d != null) {
      frc = g2d.getFontRenderContext();
      } else {
      frc = DefaultRenderContext;
      }
      }

      Which is what line 120 does.


            tprinzing Tim Prinzing (Inactive)
            rbrinkle Roger Brinkley (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: