• Post Reply Bookmark Topic Watch Topic
  • New Topic

Components in each direction of a BorderLayout  RSS feed

 
Tay Thotheolh
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I have a JFrame that has a BorderLayout. How do I find out what component(s) are in the North, Center, South...each of these directions and positions ?

Thanks for the help.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out BorderLayout#getLayoutComponent()
 
Tay Thotheolh
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Is this the correct codes (below) ?

Somehow it doesn't work.
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somehow? ... ItDoesntWorkIsUseless
Calling 'getLayoutComponent' is the exact way to achieve this, it works for me...
 
Tay Thotheolh
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a component sitting in the South but it did not println out so assuming it is null.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show the code that is adding the component in the first place? It looks like the component may not be quite where you think it is.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try it like this

//comp.getName()
comp.getClass().getName()
 
Tay Thotheolh
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks... got it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!