| bordermisc focus |
The TransferHandler object, the heart of the
data transfer system, is described in more detail later.
The arrows in the preceding diagrams show the path of the data.
Many Swing components provide out-of-the-box support for transferring data, as shown in the following table:
| Component | Drag* Copy |
Drag* Move |
Drop | Cut | Copy | Paste |
|---|---|---|---|---|---|---|
JColorChooser**
|
|
|
||||
JEditorPane
|
|
|
|
|
|
|
JFileChooser***
|
|
|
||||
JFormattedTextField
|
|
|
|
|
|
|
JList
|
|
|
||||
JPasswordField
| n/a | n/a |
|
n/a | n/a |
|
JTable
|
|
|
||||
JTextArea
|
|
|
|
|
|
|
JTextField
|
|
|
|
|
|
|
JTextPane
|
|
|
|
|
|
|
JTree
|
|
|
component.setDragEnabled(true)
on the component.
java.awt.Color.
java.io.File
objects (preferred) and as strings for those components
that do not accept File objects. The File
Name text field in the file chooser accepts strings;
the browser in the file chooser does not accept data.
Note that as of release 1.4, clipboard copy from a JFileChooser
is broken and actually causes the file to be moved when it
is pasted. You may want to watch bug
4915992otherIcon (outside of the tutorial)
The data transfer mechanism is built in to every
JComponent. For all the components
with an empty space in the preceding table only a small
amount of code is needed to customize the support.
Support can easily be added to
JComponents not listed in the table so they
can fully participate in data transfer.
The rest of this section covers the following topics:
Bhopal news
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100