• 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

layout manager

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Ranch Hand
    Posts: 131
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic