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

JColorChooser throws a NPE when applet with static reference is reloaded

XMLWordPrintable

       
      The problem with Java version 7u51

      Steps to reproduce:
      1. hit "choose color"
      2. Pick some colors under the "Swatches" tab, see the recent gets populated.
      3. Click Ok.
      4. Repeat 1 -3, so the recent gets populated nicely.
      5. Hit F5.
      6. Choose some color
      7. The moment you pick some colours again, the exception appears.

      Reproducer:

      import javax.swing.*;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      public class Chooser extends JApplet {
          private static JColorChooser chooser = new JColorChooser();

          @Override
          public void init() {
              final JButton b = new JButton("Choose Color");
              b.addActionListener(new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                      System.out.println("pop");
                      ActionListener okListener = new ActionListener() {
                          @Override
                          public void actionPerformed(ActionEvent e) {
                              System.out.println("OK");
                          }
                      };
                      ActionListener cancelListener = new ActionListener() {
                          @Override
                          public void actionPerformed(ActionEvent e) {
                              System.out.println("CANCEL");
                          }
                      };
                      final JDialog d = JColorChooser.createDialog(null,
      "replication", true, chooser, okListener, cancelListener);
                      d.setVisible(true);
                  }
              });
              add(b);
              super.init();
          }

          public static void main(String[] args) {

          }
      }
       

            dmarkov Dmitry Markov
            asaha Abhijit Saha
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: