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

JTextField is raising IllegalArgumentException because of new DnD infrastructure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • client-libs

      Run the following program and do the following, only for Windows OS:

      I got to try this on Windows 2000 & Windows 98.

      1) Type anything in the textfield.
      2) Select the entry that you've just typed.
      3) Use CTRL+C to copy the value to the clipboard.
      4) Use Backspace to erase the selected value.
      5) Use CTRL+V to try to paste the value back. The exception is raised here.

      Also, if you bring up the clipboard to see the values being placed in there, you'll notice that during the copy operation above, a special character is being inserted at the front of the selected value. On the screen of the clipboard viewer, it shows up as a square.

      ---------------------------------------------------------------------

      import javax.swing.*;

      public class SimpleTest extends JFrame {

          private JTextField textField;
          private JPanel panel;

          public static void main(String[] args) {
              new SimpleTest();
          }

          public SimpleTest() {
              textField = new JTextField(15);
              panel = new JPanel();

              panel.add(textField);

              setContentPane(panel);

              setSize(200, 200);
              show();
          }
      }

      ---------------------------------------------------------------------

      Here is the exception raised:

      java.lang.IllegalArgumentException: getTransferData() returned null
              at java.awt.datatransfer.DataFlavor.getReaderForText(DataFlavor.java:613)
              at javax.swing.plaf.basic.BasicTextUI$TextTransferHandler.importData(BasicTextUI.java:2148)
              at javax.swing.TransferHandler$TransferAction.actionPerformed(TransferHandler.java:724)
              at javax.swing.text.JTextComponent.paste(JTextComponent.java:1079)
              at javax.swing.text.DefaultEditorKit$PasteAction.actionPerformed(DefaultEditorKit.java:1219)

              at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1496)
              at javax.swing.JComponent.processKeyBinding(JComponent.java:2296)
              at javax.swing.JComponent.processKeyBindings(JComponent.java:2331)
              at javax.swing.JComponent.processKeyEvent(JComponent.java:2249)
              at java.awt.Component.processEvent(Component.java:4699)
              at java.awt.Container.processEvent(Container.java:1299)
              at java.awt.Component.dispatchEventImpl(Component.java:3459)
              at java.awt.Container.dispatchEventImpl(Container.java:1361)
              at java.awt.Component.dispatchEvent(Component.java:3326)
              at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1510)
              at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:57
      6)
              at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java
      :693)
              at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java
      :631)
              at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:548)
              at java.awt.Component.dispatchEventImpl(Component.java:3350)
              at java.awt.Container.dispatchEventImpl(Container.java:1361)
              at java.awt.Window.dispatchEventImpl(Window.java:1250)
              at java.awt.Component.dispatchEvent(Component.java:3326)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:437)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:140)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:126)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:121)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)



      edmund.lou@eng 2001-01-22
      Swing Test Development
      ============================================

            tprinzing Tim Prinzing (Inactive)
            elousunw Edmund Lou (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: