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

NPE when drag into JEditorPane with HTML content

    Details

    • Subcomponent:
    • Introduced In Build:
      b42
    • Introduced In Version:
      6
    • Resolved In Build:
      b96
    • CPU:
      generic
    • OS:
      generic

      Description

      - Compile and run the test below.
      - Drag from the "Drag From Here" component into the JEditorPane.
      - The following exception is printed:

      java.lang.IllegalArgumentException: null bias
      at javax.swing.text.DefaultCaret.setDot(DefaultCaret.java:1125)
      at javax.swing.text.JTextComponent.setDropLocation(JTextComponent.java:868)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:589)
      at sun.swing.AccessibleMethod.invoke(AccessibleMethod.java:63)
      at sun.swing.AccessibleMethod.invokeNoChecked(AccessibleMethod.java:88)
      at javax.swing.TransferHandler$DropHandler.setComponentDropLocation(TransferHandler.java:1368)
      at javax.swing.TransferHandler$DropHandler.handleDrag(TransferHandler.java:1403)
      at javax.swing.TransferHandler$DropHandler.dragEnter(TransferHandler.java:1410)
      at java.awt.dnd.DropTarget.dragEnter(DropTarget.java:337)
      at javax.swing.TransferHandler$SwingDropTarget.dragEnter(TransferHandler.java:1157)
      at sun.awt.dnd.SunDropTargetContextPeer.processEnterMessage(SunDropTargetContextPeer.java:295)
      at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEnterEvent(SunDropTargetContextPeer.java:759)
      at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(SunDropTargetContextPeer.java:727)
      at sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:30)
      at java.awt.Component.dispatchEventImpl(Component.java:4264)
      at java.awt.Container.dispatchEventImpl(Container.java:2103)
      at java.awt.Component.dispatchEvent(Component.java:4237)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4309)
      at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4098)
      at java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:4036)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3898)
      at java.awt.Container.dispatchEventImpl(Container.java:2089)
      at java.awt.Window.dispatchEventImpl(Window.java:2427)
      at java.awt.Component.dispatchEvent(Component.java:4237)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)


      TEST CASE:

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

      public class DnDTextTest extends JFrame {
          
          private JEditorPane area = createArea();
          
          public DnDTextTest() {
              super("DnDTextTest");
              getContentPane().add(new JScrollPane(area));
              
              JList dragFrom = new JList(new String[] {"Drag From Here"});
              dragFrom.setDragEnabled(true);
              dragFrom.setBorder(BorderFactory.createLoweredBevelBorder());
              getContentPane().add(dragFrom, BorderLayout.NORTH);
          }

          public static void main(String[] args) {
              DnDTextTest demo = new DnDTextTest();
              demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              demo.setSize(400, 400);
              
              Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
              demo.setLocationRelativeTo(null);
              demo.setVisible(true);
          }
          
          private JEditorPane createArea() {
              JEditorPane area = new JEditorPane();
              area.setContentType("text/html");
              area.setText("<html><body>abc</body></html>");
              area.setBorder(new EmptyBorder(20, 20, 20, 20));
              return area;
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shickeysunw Shannon Hickey (Inactive)
                Reporter:
                shickeysunw Shannon Hickey (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: