In 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
Output will be displayed as:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: October 24, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles