java - How to determine if 2 components are on the same frame? (SWING) -


this question has answer here:

i go on , iterate on parents using getparent() on each until shared parent or null, looks bad solution, there better approach?

basiclly use case in focuslistener, on focuslost() want know if losing focus thats outside frame...

you can compare result of:

swingutilities.windowforcomponent(comp1).equals(swingutilities.windowforcomponent(comp2)) 

or

swingutilities.getwindowancestor(comp1).equals(swingutilities.getwindowancestor(comp2)) 

or

swingutilities.getroot(comp1).equals(swingutilities.getroot(comp2)) 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

single sign on - Logging into Plone site with credentials passed through HTTP -