Programmatically Copying, Cutting, and PastingI want to programmatically perform copy, cut, and paste operations on text fields and text areas. Swing's abstract JTextComponent class provides programmatic copy, cut, and paste support through its copy , cut , and paste methods. These methods are inherited by its JTextField and JTextArea subclasses. When called, each method performs the appropriate operation on the component's associated text model. However, the capability to programmatically copy, cut, and paste is not present in the AWT's TextComponent , TextField , and TextArea classes. Transferring Nontextual Data to/from the System ClipboardI want to transfer nontextual data (such as an image), via the system clipboard, between Java and non-Java programs. The system clipboard, obtained by calling Toolkit 's getSystemClipboard method, doesn't appear to support the transfer of nontextual data between Java and non-Java programs. After searching a large number of Java-related Web sites and newsgroups, I have yet to uncover a technique for accomplishing this task. However, there is a pair of articles that you might want to investigate. These Microsoft Windows- related articles could help you achieve this objective. The first article shows how to use the Java Native Interface to access the Microsoft Windows system clipboard. This article is located at http://www.ddj.com/articles/ 1996/9617/9617d/9617d.htm. Although it's rather dated, it might give you some ideas. The second article shows how to save an image using Microsoft's bitmap format. This JavaWorld article is located at http://www.javaworld.com/ javaworld /javatips/f_jw-javatip60_p.html. Learning More About Drag and DropI'm still a little unclear on Drag and Drop. JavaSoft's Swing Connection contains an introductory "Drag and Drop with Swing " article. This article is located at http://java.sun.com/products/jfc/tsc/articles/dragndrop/index.html. JavaWorld has published a couple of articles that delve deeper into the Drag and Drop API:
Rockhopper Technologies has created a FAQ that answers many Drag and Drop API questions. This online FAQ is located at http://www.rockhoppertech.com/java-drag-and-drop-faq.html. |