-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta
-
sparc
-
solaris_7
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();
}
}
}
======================================================================
- duplicates
-
JDK-4408184 JTextField.copy() throws HeadlessException
-
- Closed
-
-
JDK-4408613 DefaultEditorKit.CopyAction.actionPerformed throws HeadlessException
-
- Closed
-