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 CutPastejava
If this was interesting you may be interested in this too.
13 Responses to Java Cut and Paste Primer Tutorial