0

I have a JTable that's buried in my UI. I get a Rectangle object for one of my cells. From what I understand, this cells Rectangle (aka bounds) are relative to its container (a JPanel).

What I need is this rectangles location relative to its containing JFrame. I am aware of

SwingUtilities.convertPoint(Component source,
                                 Point aPoint,
                                 Component destination)

And I call it like so:

SwingUtilities.convertPoint(jtable,
                            tableCellRectangle.getLocation(),
                            jframe);

The converted point however is not correct. I am thinking passing in the jtable is not correct. I am not sure what exactly to pass in for the first parameter. Can anyone provide insight how I can convert my point?

user489041
  • 27,916
  • 55
  • 135
  • 204
  • 3
    *"From what I understand, this cells Rectangle (aka bounds) are relative to its container (a JPanel)"* - To the `JTable`. *"The converted point however is not correct. I am thinking passing in the jtable is not correct. Can anyone provide insight how I can convert my point?"* - Consider providing a [runnable example](https://stackoverflow.com/help/mcve) which demonstrates your problem. This is not a code dump, but an example of what you are doing which highlights the problem you are having. This will result in less confusion and better responses – MadProgrammer Feb 25 '15 at 01:14
  • Maybe this might help: http://stackoverflow.com/questions/12589824/get-location-of-a-swing-component – Araymer Feb 25 '15 at 01:15
  • 2
    *"Getting position of Component in Swing"* ...why? – Andrew Thompson Feb 25 '15 at 01:40
  • @AndrewThompson Because I am painting something above it – user489041 Feb 25 '15 at 13:25

0 Answers0