/** * The paste method has been overloaded to strip off the <html><body> tags * This doesn't really work. */ @Override public void paste() { Clipboard clipboard = getToolkit().getSystemClipboard(); Transferable content = clipboard.getContents(this); if (content != null) { DataFlavor[] flavors = content.getTransferDataFlavors(); try { for (int i = 0; i < flavors.length; i++) { if (String.class.equals(flavors[i].getRepresentationClass())) { Object data = content.getTransferData(flavors[i]); if (flavors[i].isMimeTypeEqual("text/plain")) { // This works but we lose all the formatting. replaceSelection(data.toString()); break; } } } } catch (Exception ex) { // TODO change to something meaningful - when can this acutally happen? LOG.log(Level.FINE, "What can produce a problem with data flavor?", ex); } } }
/** * The paste method has been overloaded to strip off the <html><body> tags * This doesn't really work. */ @Override public void paste() { Clipboard clipboard = getToolkit().getSystemClipboard(); Transferable content = clipboard.getContents(this); if (content != null) { DataFlavor[] flavors = content.getTransferDataFlavors(); try { for (int i = 0; i < flavors.length; i++) { if (String.class.equals(flavors[i].getRepresentationClass())) { Object data = content.getTransferData(flavors[i]); if (flavors[i].isMimeTypeEqual("text/plain")) { // This works but we lose all the formatting. replaceSelection(data.toString()); break; } } } } catch (Exception ex) { // TODO change to something meaningful - when can this acutally happen? LOG.log(Level.FINE, "What can produce a problem with data flavor?", ex); } } }
/** * The paste method has been overloaded to strip off the <html><body> tags * This doesn't really work. */ @Override public void paste() { Clipboard clipboard = getToolkit().getSystemClipboard(); Transferable content = clipboard.getContents(this); if (content != null) { DataFlavor[] flavors = content.getTransferDataFlavors(); try { for (int i = 0; i < flavors.length; i++) { if (String.class.equals(flavors[i].getRepresentationClass())) { Object data = content.getTransferData(flavors[i]); if (flavors[i].isMimeTypeEqual("text/plain")) { // This works but we lose all the formatting. replaceSelection(data.toString()); break; } } } } catch (Exception ex) { // TODO change to something meaningful - when can this acutally happen? LOG.log(Level.FINE, "What can produce a problem with data flavor?", ex); } } }
/** * The paste method has been overloaded to strip off the <html><body> tags * This doesn't really work. */ @Override public void paste() { Clipboard clipboard = getToolkit().getSystemClipboard(); Transferable content = clipboard.getContents(this); if (content != null) { DataFlavor[] flavors = content.getTransferDataFlavors(); try { for (int i = 0; i < flavors.length; i++) { if (String.class.equals(flavors[i].getRepresentationClass())) { Object data = content.getTransferData(flavors[i]); if (flavors[i].isMimeTypeEqual("text/plain")) { // This works but we lose all the formatting. replaceSelection(data.toString()); break; } } } } catch (Exception ex) { // TODO change to something meaningful - when can this acutally happen? LOG.log(Level.FINE, "What can produce a problem with data flavor?", ex); } } }
/** * The paste method has been overloaded to strip off the <html><body> tags * This doesn't really work. */ @Override public void paste() { Clipboard clipboard = getToolkit().getSystemClipboard(); Transferable content = clipboard.getContents(this); if (content != null) { DataFlavor[] flavors = content.getTransferDataFlavors(); try { for (int i = 0; i < flavors.length; i++) { if (String.class.equals(flavors[i].getRepresentationClass())) { Object data = content.getTransferData(flavors[i]); if (flavors[i].isMimeTypeEqual("text/plain")) { // This works but we lose all the formatting. replaceSelection(data.toString()); break; } } } } catch (Exception ex) { // TODO change to something meaningful - when can this acutally happen? LOG.log(Level.FINE, "What can produce a problem with data flavor?", ex); } } }