Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swing text组件无法从剪贴板粘贴大型文本数据:java.io.IOException:所有者无法转换数据_Java_Swing_Exception_Jtextarea_Ioexception - Fatal编程技术网

Swing text组件无法从剪贴板粘贴大型文本数据:java.io.IOException:所有者无法转换数据

Swing text组件无法从剪贴板粘贴大型文本数据:java.io.IOException:所有者无法转换数据,java,swing,exception,jtextarea,ioexception,Java,Swing,Exception,Jtextarea,Ioexception,我直接使用JTextArea,并通过JTextComponent接口尝试将基于swing的应用程序(记事本)外部的文本数据粘贴到应用程序中 使用两种不同的方法(如下所示),对于大量文本数据,我似乎得到了相同的结果。只要我坚持少量(java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76))就行 at>java.security.ProtectionDomain$1.doIntersectio

我直接使用JTextArea,并通过JTextComponent接口尝试将基于swing的应用程序(记事本)外部的文本数据粘贴到应用程序中

使用两种不同的方法(如下所示),对于大量文本数据,我似乎得到了相同的结果。只要我坚持少量(java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76))就行 at>java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) 在java.awt.EventQueue$4.run(EventQueue.java:708) 在java.awt.EventQueue$4.run(EventQueue.java:706) 位于java.security.AccessController.doPrivileged(本机方法) at>java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 位于java.awt.EventQueue.dispatchEvent(EventQueue.java:705) 位于java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) 在java.awt.EventDispatchThread.PumpeEventsforFilter(EventDispatchThread.java:161) 位于java.awt.EventDispatchThread.PumpeEventsforHierarchy(EventDispatchThread.java:150) 位于java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) 位于java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) 在java.awt.EventDispatchThread.run(EventDispatchThread.java:91) ==更新==


额外的测试似乎表明,这只发生在Linux操作系统(我用于开发)上,但它似乎在windows上运行(我不使用)。不知道它是否能更好地处理大数据,但您可以尝试使用DefaultEditorKit中的默认操作进行复制:

JButton paste = new JButton( new DefaultEditorKit.PasteAction() );

该操作也可以添加到JMenuItem。

它实际上没有,但感谢您的建议。
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable t = c.getContents(this);
if (t == null)
    return;
try {
    component.setText((String) t.getTransferData(DataFlavor.stringFlavor));
} catch (Exception e){
    e.printStackTrace();
}
11:35:21.030 [AWT-EventQueue-0] DEBUG c.a.y.a.c.e.CopyPasteMouseListener - Running paste java.io.IOException: Owner failed to convert data at sun.awt.X11.XSelection.validateDataGetter(XSelection.java:444) at sun.awt.X11.XSelection.getData(XSelection.java:378) at sun.awt.X11.XClipboard.getClipboardData(XClipboard.java:120) at sun.awt.datatransfer.ClipboardTransferable.fetchOneFlavor(ClipboardTransferable.java:118) at sun.awt.datatransfer.ClipboardTransferable.(ClipboardTransferable.java:97) at sun.awt.X11.XClipboard.getContents(XClipboard.java:106) at com.adjuggler.yorick.ajentconsole.console.editors.CopyPasteMouseListener.actionPerformed(CopyPasteMouseListener.java:75) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3320) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:708) at java.awt.EventQueue$4.run(EventQueue.java:706) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:705) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154) at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182) at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221) at java.security.AccessController.doPrivileged(Native Method) at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219) at java.awt.Dialog.show(Dialog.java:1082) at java.awt.Component.show(Component.java:1651) at java.awt.Component.setVisible(Component.java:1603) at java.awt.Window.setVisible(Window.java:1014) at java.awt.Dialog.setVisible(Dialog.java:1005) at com.adjuggler.yorick.ajentconsole.console.editors.ConfigBox$4.actionPerformed(ConfigBox.java:183) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3320) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:708) at java.awt.EventQueue$4.run(EventQueue.java:706) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:705) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154) at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182) at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221) at java.security.AccessController.doPrivileged(Native Method) at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219) at java.awt.Dialog.show(Dialog.java:1082) at java.awt.Component.show(Component.java:1651) at java.awt.Component.setVisible(Component.java:1603) at java.awt.Window.setVisible(Window.java:1014) at java.awt.Dialog.setVisible(Dialog.java:1005) at com.adjuggler.yorick.ajentconsole.console.Console.doSettingsButton(Console.java:1510) at com.adjuggler.yorick.ajentconsole.console.Console.actionPerformed(Console.java:716) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3320) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at >java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at >java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:708) at java.awt.EventQueue$4.run(EventQueue.java:706) at java.security.AccessController.doPrivileged(Native Method) at >java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:705) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
JButton paste = new JButton( new DefaultEditorKit.PasteAction() );