The System Clipboard

As you can see in Figure 20-1, our first applet contains a textfield, a textarea, and two buttons. After text is typed into the textfield, activating the Copy To System Clipboard button places the textfield's text onto the system clipboard. Subsequently, activating the “Paste From System Clipboard” button retrieves the text currently on the clipboard and places it in the textarea.

Figure 20-1. Copying a String to the System Clipboard. Activating the Copy To System Clipboard button copies the text from the textfield and places it on the system clipboard.

Before listing the applet in its entirety, let's take a look at the code ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.