Clipboard provides application to transfer data. Here, we have used Swing and AWT package to illustrates you the use of method getSystemClipboard().
Ads
TutorialsIn this section, you will study how to use the method getClipboard().
Clipboard provides application to transfer data. Here, we have used Swing and AWT package to illustrates you the use of method getSystemClipboard(). In this example, you can copy and paste the text on the text field.
The method getSystemClipboard() provides the clipboard facilities to transfer data. The method area.getSelctedText() returns the selected text of the text component. This selected text is then add to the clipboard using the method clipboard.setContents(). The method getClipboardContents() get the contents added to the clipboard. Then using the class Transferable the content of the clipboard get transfered using the method getTransferData(). The method replaceSelection() returns the selected text.
Here is the code of GetClipboard.java
import java.awt.*;
|
Output will be displayed as:
Posted on: October 24, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles
Advertisements
Ads
Ads
Discuss: Java Get Clipboard
Post your Comment