The clipboard is an important part of the GUI aspects to Windows and Mac OS X, and even non-GUI DOS windows or Unix/Linux console windows would have functionality to cut, paste and copy string data.
Today’s Java program shows cut and paste functionality in action from within a program accessing the operating system’s clipboard.
Also touched on today are:
- Javac’s Xlint non-standard option tool by Oracle (and formerly by Sun) for warnings regarding cast, deprecation, divzero, empty, fallthrough, finally, overrides, path, serial
- Show you glimpse of vi (the great Linux/Unix text editor)
So, today, with our tutorial we use the class StringSelection implementing the Transferable and ClipboardOwner interfaces to create the resultant Java GUI program.
This tutorial’s code is very close to that presented in Java Examples in a Nutshell by David Flanagan (pp. 142-144).
Link to Java programming source code which you should rename to CutPaste.java
If this was interesting you may be interested in this too.