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

Second mouse click in empty JFileChooser view causes NPE

    XMLWordPrintable

Details

    • 1.2.2
    • generic, x86
    • generic, windows_nt

    Description



      Name: dbT83986 Date: 01/10/99


      To reproduce error:
      1) Run the application below from the dosprompt. Click the button to open the FileChooser
      2) Move to an empty dir.
      3) Click the empty filechoosing area. (you might need to do it a couple of times).
      That gives you an unhandled exception.

      Exception occurred during event dispatching:
      java.lang.NullPointerException:
              at javax.swing.plaf.metal.MetalFileChooserUI$SingleClickListener.mouseClicked(Metal
      FileChooserUI.java:383)
              at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:211)
              at java.awt.Component.processMouseEvent(Component.java:3129)
              at java.awt.Component.processEvent(Compiled Code)
              at java.awt.Container.processEvent(Compiled Code)
              at java.awt.Component.dispatchEventImpl(Compiled Code)
              at java.awt.Container.dispatchEventImpl(Compiled Code)
              at java.awt.Component.dispatchEvent(Compiled Code)
              at java.awt.LightweightDispatcher.retargetMouseEvent(Compiled Code)
              at java.awt.LightweightDispatcher.processMouseEvent(Compiled Code)
              at java.awt.LightweightDispatcher.dispatchEvent(Compiled Code)
              at java.awt.Container.dispatchEventImpl(Compiled Code)
              at java.awt.Window.dispatchEventImpl(Compiled Code)
              at java.awt.Component.dispatchEvent(Compiled Code)
              at java.awt.EventQueue.dispatchEvent(Compiled Code)
              at java.awt.EventDispatchThread.run(Compiled Code)

      You will also get an exception when you click in the lower part in the filechoosing area when the filechoosing area is not
      completely covered by file names or dirs.

      Another thing. If you enlarge the FileChooser by resizing it, which is
      a nice feature, the field for the filename is also resized. It should
      only be resized horizontally since it can contain only one line of
      text. That would also give more useful space to the filechoosing area.


      import javax.swing.*;
      import javax.swing.filechooser.*;
      import java.awt.*;
      import java.awt.event.*;

      public class FileChooserError extends JFrame implements ActionListener {
        public static void main(String args[]) {
          FileChooserError fce = new FileChooserError();
          fce.pack();
          fce.show();
        }
        public FileChooserError() {
          super("Example of null pointer exception");
          Button indError = new Button("Open Filechooser");
          indError.addActionListener(this);
          getContentPane().add(indError, BorderLayout.CENTER);
        }
        public void actionPerformed(ActionEvent e) {
          JFileChooser jfc = new JFileChooser();
          jfc.showOpenDialog(this);
        }
      }
      (Review ID: 52387)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              jeff Jeff Dinkins
              dblairsunw Dave Blair (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: