• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get a component from x / y coords

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I have a JPanel with about 4 components in it
I can get the position of a component using GridBagConstraints.
is there anyway I can get the instance of the component using the coordinates?
I tried using getComponentAt() but that just returns the whole JPanel.
myPanel.getComponentAt(x, y)
What I'm trying to do is get the component that is next to the compnenet I have selected.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try findComponentAt(x,y). I'm vague on how these methods differ, but the "find" version definitely claims to drill down through containers to find the visible component. The "get" version doesn't really specify what it does, although I suppose we could look at the code.
reply
    Bookmark Topic Watch Topic
  • New Topic