Troubleshooting

   

Programmatically Copying, Cutting, and Pasting

I 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 Clipboard

I 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 Drop

I'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:

  • The two-part "How to Drag and Drop with Java 2 " provides a comprehensive look at the Drag and Drop API architecture. The first part is located at http://www.javaworld.com/javaworld/jw-03-1999/jw-03-dragndrop.html, and the second part is located at http://www.javaworld.com/javaworld/jw-08-1999/jw-08-draganddrop.html.

  • "Java Tip 97: Add Drag and Drop to Your Jtrees " shows how to add Drag and Drop API support to JTree components . This article is located at http://www.javaworld.com/javaworld/javatips/jw-javatip97.html.

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.

   


Special Edition Using Java 2 Standard Edition
Special Edition Using Java 2, Standard Edition (Special Edition Using...)
ISBN: 0789724685
EAN: 2147483647
Year: 1999
Pages: 353

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net