On Mar 13, 11:34 pm, Thomas Fritsch <i.dont.like.s...@invalid.com>
wrote:
> > I have successfully implemented cut/copy/paste in a JTree by
> > implmenting my own TransferHandler and Transferrable object. It works
[quoted text clipped - 38 lines]
> --
> Thomas
> Which JComponent do you want to support cut/copy/paste, the JLabels or
the JPanel?
The JLabels will be the actual things that are cut/copy/pasted but
they will be cut/copy/pasted into the JPanel. So, I want to support
cut/copy/paste in the JPanel. My underlying TransferHandler handles
the labels.
> Did you set up a TransferHandler for your JComponent?
Yes
> Did you set up the input/action-mappings for your JComponent
Ah...I didn't do that. I didn't think I had to. So far, everything
has "just worked." (I have already done this for a JTree.) Do you
think I need to do this for the JPanel when it already works in the
JTree?
> Did you implement your own subclass of TransferHandler
Yes. Similar to what I did with my own JTree implementation, which
works great.
I'll look into the action mappings as that would make sense for the
problem I'm having. If you have any other suggestions based on my
feedback, I'd be interested in hearing that, too.
Thanks for your help.
Thomas Fritsch - 14 Mar 2007 11:35 GMT
Jason Cavett schrieb:
[...]
> If you have any other suggestions based on my
> feedback, I'd be interested in hearing that, too.
My IDE with its debugger has helped me a lot to understand what is
really going on.
Therefore I suggest: Launch your favorite IDE, set a breakpoint in
method TransferHandler$TransferAction.actionPerformed (which is the
common core of TransferAction.getCut/Copy/PasteAction), start your
application, type control-C (-> the debugger should break now), walk
through step-by-step, and see how things work.

Signature
Thomas
Jason Cavett - 14 Mar 2007 20:35 GMT
On Mar 14, 6:35 am, Thomas Fritsch <i.dont.like.s...@invalid.com>
wrote:
> Jason Cavett schrieb:
> [...]> If you have any other suggestions based on my
[quoted text clipped - 10 lines]
> --
> Thomas
Sweet! It works. Thank you very much.
I am still having a problem in that my toolbar cannot trigger actions
on a component (cut/copy/paste) even though the menu bar works fine.
I followed the instructions in the tutorial again, but when I click a
button in the (graphical) toolbar, the action does not seem to
remember what component last had focus like it does when I click on an
item in the menu bar.
Would you happen to know anything about this?
Again, thank you very much for your help. It is/was much appreciated.
Jason Cavett - 14 Mar 2007 21:35 GMT
> On Mar 14, 6:35 am, Thomas Fritsch <i.dont.like.s...@invalid.com>
> wrote:
[quoted text clipped - 26 lines]
>
> Again, thank you very much for your help. It is/was much appreciated.
Well, I have figured out one way to prevent the buttons from gaining
focus when I click on them and that's by setting them to
isFocusable(false). It works, but it seems *somewhat* hackish.
What do you think?
Thomas Fritsch - 15 Mar 2007 14:18 GMT
Jason Cavett schrieb:
> Well, I have figured out one way to prevent the buttons
...you're talking about the toolbar-buttons, don't you?
> from gaining
> focus when I click on them and that's by setting them to
> isFocusable(false). It works, but it seems *somewhat* hackish.
Not necessarily.
May be there is a convention whether toolbar-buttons should be
non-focusable. I've looked through some native Windows-apps (Mozilla,
IE), and they all have non-focusable toolbar-buttons (i.e. they are not
reachable by the TAB-key).
> What do you think?

Signature
Thomas