I am trying to test drag and drop,
where the place I am dragging from is
a JTree inside of a JScrollPane inside a JDialog.
I will be dropping on another part of the same JDialog.
Basically what I want to do next is to scroll the TreeNode I want
so it is visible, find its x, y coordinates, and then do a MousePress
at that position.
My test class extends ComponentTestFixture,
and as class variables, I have a bunch of testers,
including a JTreeTester named _treeTester.
I have a TreePath, both in the form of Strings, as Abbot likes,
and in the form of TreeNodes, as JTree seems to prefer.
using the String kind of path,
expands the TreeNodes properly
but does not scroll the TreeNode I want so I can see it.
The call to scrollPathToVisible on the JTree,
with the TreeNode kind of path,
doesn't seem to do anything.
I have managed to make the scrolling happen by manually setting
the value of the JScrollBar.
However, calling getPathBounds on the JTree
persists in returning null as a Rectangle,
whether the TreeNode I want is visible or not.
This null return means that
JTreeLocation.getPoint() throws an Exception,
so I cannot get the x, y for my MousePress that way.
I have tried setting the UI manually to the MetalUI,
in case the default was something nonstandard.
That did not help either.
I am doing this testing on SUSE Linux for whatever that is worth.
Does anyone have suggestions
on how to make this work?
Is there some other way to test this
that I have not yet understood?
I have another JTree in the main JFrame,
and the scrolling for that seems to work just fine,
so I suspect there is something different
about being in a JDialog.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.