I have a JPanel loaded on top of JXTreeTable. I want to determine if JPanel overlaps a particular cell of JXTreeTable. I tried retriving the X and Y components and comparing them. However when I check the JPanel's minimum X and Y co-ordinates, they are always 0.0. I am not able to figure out that. Is there any other than than just comparing the co-ordinate values?
You should be able to use Rectangle to help determine if the components are overlapping.
ie
Rectangle panelBounds = panel.getBounds();
Rectangle cellBounds = getRowBounds(row); // getPathBounds(path);
if (panelBounds.intersects(cellBounds)) {
// We have a collision
}
Now, you bigger problem is, the X/Y return value always been 0. This means that the Rectangle return by the getBounds method will also return x/y of 0.
You will need share some code to show us how you laying out this component.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With