Submitted On 28-APR-2003
coxcu
How does the protected scope of createTransferable and
importDone prevent the construction of composite
TransferHandlers?
Submitted On 29-APR-2003
shan-man
Answer to coxcu's question:
The protected scope of those two methods prevents the
approach where one TransferHandler wraps another. A
TransferHandler subclass cannot invoke protected methods on
instances of the TransferHandler class. This makes delegation
impossible.
This may sound unintuitive, and it took me awhile to figure
out what was wrong. I found the answer in the VM spec:
http://java.sun.com/docs/books/jls/second_edition/html/name
s.doc.html#62587
http://java.sun.com/docs/books/jls/second_edition/html/name
s.doc.html#36191
http://java.sun.com/docs/books/tutorial/java/javaOO/accessc
ontrol.html
Submitted On 16-SEP-2003
DragonRider_11
I have an idea. I haven't tried it out yet but it goes
something like this:
Subclass the TransfareHandler and provide a public API to
these methods, then create a wrapper arround the subclass
as proposed.
Submitted On 30-SEP-2003
mgsun
Subclassing TransferHandler works of course but what we want
to do is subclass an internal TransferHandler class which
inside the BasicTextUI.
Hwoever -if you only want to paste data from the clipboard
into the textcomponent (not copy or move data out fo the
component) the delegate approach seems to work fine as you
do not need to overwrite the protected methods.
Submitted On 26-MAR-2004
RedSolo
Ive stumbled upon this problem as well And I dont see
the problem of making those methods public, I doubt
that any malicious code could be doing anything bad
with the data it gets from the createTransferable()
method.
Ive fixed a workaround for this problem, through using
the reflection API. This is not my preferred way of
implementing but it is the only way to make it possible.
This TransferHandler can take multiple handlers, and
using the chain of responsibility to find out if the any of
the added transfer handlers are capable of handling
specific DataFlavors.
MultipleTransferHandler can be found at:
http://cvs.sourceforge.net/viewcvs.py/columba/frapuccin
o/src/java/org/frappucino/swing/MultipleTransferHandle
r.java
http://redsolo.blogspot.com/2004_03_01_redsolo_arch
ive.html#108004595020752861
Full java source describing the problem at:
http://forum.java.sun.com/thread.jsp?
forum=57&thread=506004
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|