Reputation: 13386
I want to add widgets by double clicking, so I've added EditAction to my scene and overrode EditProvider's edit
method. Now the problem is that I want to set initial position of the widget to my mouse position. I've found out that I can use
MouseInfo.getPointerInfo().getLocation()
to get my mouse's location, but it's relative to the screen. I've also read that people use
component.getLocationOnScreen()
to subtract parent's location on screen from the mouse's one, but my scene doesn't seem to implement it.
Upvotes: 0
Views: 1346
Reputation: 1067
After creating a Scene, you need to use createView() (to create the view JComponent) or getView() (to access the already-created JComponent instance).
You can use your JComponent instance (after it is created) to obtain the component's location on screen:
scene.getView().getLocationOnScreen()
Upvotes: 1