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:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.