If the returned transferable isn't null, paste() invokes isDataFlavorSup-
ported() on this object with DataFlavor.stringFlavor as the argument.
This method returns true when the requested flavor is supported. In other words,
isDataFlavorSupported() returns true when the clipboard contains text; it
would return false when the clipboard contained an image (for example).
If isDataFlavorSupported() returnstrue, paste() calls getTransfer-
Data() to return the string and then replaces the selected string with this content.
TextArea contains built-in support for performing copy, cut, and paste operations
by pressing the Ctrl-C, Ctrl-X, and Ctrl-V key combinations. However, neither Tex-
tArea nor its TextComponent superclass provides methods for performing these
tasks.Asaresult,youwouldhavetosupplyyourown copy() , cut() ,and paste()
methods (such as those shown previously) when youwanted to programmatically per-
an Edit menu).
I've created a CopyCutAndPaste application that demonstrates copy, cut, and
pasteonatextareaviatheprevious copy() , cut() ,and paste() methods.Consult
thisbook'scodefilefor CopyCutAndPaste 'ssourcecode.(Thisbook'sintroduction
presents instructions on obtaining the code file.)
Swing is a windowing system-independent API for creating GUIs that are based on
components, containers, layout managers, and events. Although Swing extends AWT
(you can use AWT layout managers and events in your Swing GUIs), this API differs
from its predecessor in several ways, including the following:
dows and a Motif button on X Window-Motif. In contrast, a Swing GUI can
look and feel the same when run on any windowing system or (at the deve-
loper's discretion) adopt the look and feel of the windowing system on which
mon denominator ofcomponent features. Forexample, if buttons onone win-
dowing system can display images with text whereas buttons on another win-