Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

layout manager

 
mani senthil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which layout manager is best to pace the controls over a window as our wish? That is by mentioning X, Y position.
 
Campbell Ritchie
Sheriff
Posts: 48441
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The whole idea of a layout manager is that you don't enter the x, y coordinates of a component in a container. that is called "absolute positioning" or the "null layout."
Find any decent book and read about layout managers (eg C Horstmann, G Cornell, Core Java 2 vol 1: fundamentals, Santa Clara: Sun Microsystems Press (Prentice-Hall) (2004), page 345ff, 424ff). The advantages of a manager over null positioning, according to Horstmann and Cornell are:-
  • It is easier to alter the size of components to match their contents.
  • Components do not "fall off" the edge of the container when it is resized."
  • If you insist on using absolute positioning, try:-. . . or similar.

    I would suggest you read Horstmann, understand their GBC class (see page 433 or here, and use GridBag. But it is the most awkward manager to learn.
     
    Ricky Clarkson
    Ranch Hand
    Posts: 131
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There are some disadvantages to using null layout rather than an actual written AbsoluteLayout, or XYLayout.

    I think I'm starting to favour allowing absolute positioning, on YAGNI grounds.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic