Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2178

Re: Dragging JInternalFra

From "Laird Nelson" <laird.nelson@THRWHITE.remove-dii-this>
Subject Re: Dragging JInternalFra
Message-ID <1185991264.180510.129250@d55g2000hsg.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <1185822611.700538.101390@b79g2000hse.googlegroups.com>
Date 2011-04-27 15:37 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
On Jul 30, 3:10 pm, Laird Nelson <ljnel...@gmail.com> wrote:
> My, what a stupid post I made.  My apologies; there is no such
> method.  Carry on.

Let's try once more.

I know that there is not a setDragEnabled() method now; that's only on
commonly draggable components (like JTree etc.).  I had been laboring
under the silly delusion that it was on all JComponents.  All better
now.

I also know about TransferHandlers and Transferables and all of that,
having done drag and drop before from trees to tables and so forth.

Onwards.

I have an odd case where I need--well, would like--to be able to drag
an internal frame onto a JTree node.  More specifically, I'd like it
to be the case that if I'm dragging the frame around on its JDesktop,
but release the mouse while it's over a JTree outside of that
JDesktop, that the tree accept a drop of the data logically contained
by the frame.

So assume the frame contains a...I don't know, some GUI component
displaying a Person.  And the tree has a node that can potentially
contain Persons.  If you drag the internal frame towards the edge of
the desktop, but release the mouse while it's over the Persons tree
node, I'd like a copy of that Person (or a reference; I can handle
that part) to be dropped on the tree.

Finally, I don't want this to get in the way of the LookAndFeel-
controlled frame drag--that is, just because you drag the frame into
the tree, it should still move around on the JDesktop.  I'm looking
to...add, I guess, superimpose, augment dragging behavior on top of
the LookAndFeel-controlled frame dragging behavior.

The problem, as I see it, is severalfold:

1. Whose TransferHandler should control the drag?  JDesktopPane?
Normally (in JTable and JTree) the container (the JTable or the JTree)
controls the dragging of its innards (like TreeNodes, rows, etc.).
This feels a _wee_ bit odd in the case of a JDesktopPane, since the
JInternalFrame actually gets the drag initiation in normal cases.  But
I'm not looking to drag anything _in_ the JInternalFrame; I'm looking
to drag the JInternalFrame itself.

2. All things being equal, I don't really want to start the drag and
drop machinery until the mouse leaves the JDesktopPane boundaries.  My
naive first pass at this failed--I tried installing a MouseListener on
the desktop that listened for mouseExited() events with the button
down (this felt like an awful hack, but I at least wanted to see what
happened).  What happened was the event was not reported--because a
drag of the internal frame WITHIN the desktop was underway, no
mouseExited events got delivered to the desktop.

3. Assuming I could ever get this far, when the drop occurs I would
want, obviously, the drop on the tree to take place, but I'd also like
the internal frame to "land" where it normally would on the desktop.
I don't think I have to do anything special here, but you never know.

4. Squinting my eyes and backing up to 5,000 feet I don't really see a
set of APIs for adding behavior to some of the Basic*UI drag
recognition machinery.  Is there a way to do this without hacking?

5. Finally, has anyone done this?

Thanks,
Laird

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Dragging JInternalFra "Laird Nelson" <laird.nelson@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000
  Re: Dragging JInternalFra "Laird Nelson" <laird.nelson@THRWHITE.remove-dii-this> - 2011-04-27 15:37 +0000

csiph-web