JDK-4197992 : JComponent (JProgressBar) update(Graphics) throws NullPointerException
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-12-16
  • Updated: 1999-02-01
  • Resolved: 1999-02-01
Related Reports
Duplicate :  
Description

Name: dbT83986			Date: 12/16/98


Calling JComponent.update(Graphics g) throws an exception NullPointerException even though the JComponent and
the Graphics are not null.

Easy to reproduce!

This worked correctly in JDK 1.1.7A.  Now with JDK 1.2 release for Windows NT (downloaded 12/04/98), it fails.  This code 
below is a very simplifed version of my code which now fails consistently.

If I don't get a fix or workaround soon, I'll have to revert back to 1.1.7A.

// --------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class JProgress_update
      extends JFrame
{
  private JProgressBar progress;
  
  public static void main(String[] args)
  {
   new JProgress_update();
  }

  public JProgress_update()
  {
    super("JProgress_update");
    
    // Window adapter to listen for frame closing
    addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent event)
      {
        System.exit(0);
      }
    });

    Container client = getContentPane();
    client.setLayout(new BorderLayout());
	
    progress = new JProgressBar(0,100);
    client.add(progress, BorderLayout.CENTER);

    setSize(400,300);
    show();
    progress.setValue(27);
    progress.update(progress.getGraphics());    
  }
}  // JInfoProgress_update
(Review ID: 47511)
======================================================================

Comments
PUBLIC COMMENTS Calling repaint should definately suffice. The clip rect was null in this case, and bug 4191142 fixed that, refer to it for more information. scott.violet 1999-02-01
10-06-2004

EVALUATION I don't know why they are calling update directly -- calling repaint() should suffice. jeff.dinkins@Eng 1999-01-07 Calling repaint should definately suffice. The clip rect was null in this case, and bug 4191142 fixed that, refer to it for more information. scott.violet 1999-02-01
07-01-1999