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

JTextComponent.cut,copy,paste throws HeadlessException

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_7

      Description



      Name: sdR10048 Date: 01/29/2001


      public void
        javax.swing.text.JTextComponent.cut()
        javax.swing.text.JTextComponent.copy()
        javax.swing.text.JTextComponent.paste()

      throws unspecified HeadlessException in headless mode.

      Javadoc says:
      --------------------------------------------------
      public void cut()

           Transfers the currently selected range in the associated text
           model to the system clipboard, removing the contents from the
           model. The current selection is reset. Does nothing for null
           selections.
           See Also:
                Toolkit.getSystemClipboard(), Clipboard


      public void copy()

           Transfers the currently selected range in the associated text
           model to the system clipboard, leaving the contents in the text
           model. The current selection remains intact. Does nothing for
           null selections.
           See Also:
                Toolkit.getSystemClipboard(), Clipboard


      public void paste()

           Transfers the contents of the system clipboard into the
           associated text model. If there is a selection in the associated
           view, it is replaced with the contents of the clipboard. If there
           is no selection, the clipboard contents are inserted in front of
           the current insert position in the associated view. If the
           clipboard is empty, does nothing.
           See Also:
                replaceSelection(java.lang.String), Toolkit.getSystemClipboard(),
                Clipboard

      See example:
      --------------------------------------------------
      [falcon] ~/tmp
      % cat Test.java
      import javax.accessibility.*;
      import java.awt.event.*;
      import java.awt.*;
      import javax.swing.*;
      import javax.swing.text.*;

      public class Test {
          public static void main(String args[]) {
              JTextField c = new JTextField();

              System.out.println("---copy---");
              try {
                  c.copy();
              } catch (Exception e) {
                  System.out.println(e);
              }

              System.out.println("---cut---");
              try {
                  c.cut();
              } catch (Exception e) {
                  System.out.println(e);
              }

              System.out.println("---paste---");
              try {
                  c.paste();
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }

      [falcon] ~/tmp
      % javac Test.java

      [falcon] ~/tmp
      % j -Djava.awt.headless=true Test
      ---copy---
      java.awt.HeadlessException
      ---cut---
      java.awt.HeadlessException
      ---paste---
      java.awt.HeadlessException
              at sun.awt.HeadlessToolkit.getSystemClipboard(HeadlessToolkit.java:278)
              at javax.swing.TransferHandler$TransferAction.getClipboard(TransferHandler.java:735)
              at javax.swing.TransferHandler$TransferAction.actionPerformed(TransferHandler.java:716)
              at javax.swing.text.JTextComponent.paste(JTextComponent.java:1079)
              at Test.main(Test.java:27)
      ^C
      [falcon] ~/tmp
      % java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b48)
      Java HotSpot(TM) Client VM (build 1.4beta-B48, mixed mode)

      ======================================================================

      Name: sdR10048 Date: 01/29/2001


      NOTE: the following method has the same problem:
      javax.swing.text.JTextComponent.setDragEnabled(boolean)
      if input parameter == true
      The simple test is:

      public class Test {
          public static void main(String args[]) {
              try {
                  (new javax.swing.JTextField()).setDragEnabled(true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tprinzinsunw Timothy Prinzing (Inactive)
                Reporter:
                dsvsunw Dsv Dsv (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: