Creating an Example Program
It's time to get down to business and create some programs that use the clipboard techniques discussed so far. The first program you'll build uses a private clipboard. It copies or cuts data from a TextField object in response to the Copy and Paste buttons. When the user clicks the Paste button, any text in the clipboard is transferred into the read-only TextField object.
Listing 11.2 shows you the source code. Take a look at it and then read the explanation that follows.
Listing 11.2 Source Code for the PrivateClipboard Program That Demonstrates Using a Private Clipboard
import com.sun.java.swing.*; import java.awt.*; import java.awt.datatransfer.*; import java.awt.event.*; import javax.swing.*; public class PrivateClipboard ... |
Get JavaBeans Unleashed 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.