Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li><blockquote> <p>Should I completely avoid the use of those methods?</p> </blockquote> <p>Yes for application code.</p></li> <li><blockquote> <p>The methods have been defined for a reason. So when should I use them? In which context? For what purposes?</p> </blockquote> <p>I don't know, personally I think of it as an API design accident. Slightly forced by compound components having special ideas about child sizes. "Slightly", because they should have implemented their needs with a custom LayoutManager.</p></li> <li><blockquote> <p>What exactly are the negative consequences of using those methods? (I can only think adding portability between systems with different screen resolution.)</p> </blockquote> <p>Some (incomplete, and unfortunately the links are broken due to migration of SwingLabs to java.net) technical reasons are for instance mentioned in the <a href="http://web.archive.org/web/20110614145256/http://wiki.java.net/twiki/bin/view/Javadesktop/SwingLabsImperialRules?TWIKISID=e1a6667476691b56753dc9b0744828c6#Do_not_use_component_setXXSize" rel="noreferrer">Rules (hehe)</a> or in the <a href="http://web.archive.org/web/20100207211337/http://www.jguru.com/faq/view.jsp?EID=237070" rel="noreferrer">link</a> @bendicott found in his/her comment to <a href="https://stackoverflow.com/questions/7074514/images-in-jtable-cells-off-by-one-pixel">my answer</a>. Socially, posing tons of work onto your unfortunate fellow who has to maintain the code and has to track down a broken layout.</p></li> <li><blockquote> <p>I don't think any LayoutManager can exactly satisfy all desired layout needs. Do I really need to implement a new LayoutManager for every little variation on my layout?</p> </blockquote> <p>Yes, there are LayoutManagers powerful enough to satisfy a very good approximation to "all layout needs". The big three are JGoodies FormLayout, MigLayout, DesignGridLayout. So no, in practice, you rarely write LayoutManagers except for simple highly specialized environments.</p></li> <li><blockquote> <p>If the answer to 4 is "yes", won't this lead to a proliferation of LayoutManager classes which will become difficult to maintain? </p> </blockquote> <p>(The answer to 4 is "no".)</p></li> <li><blockquote> <p>In a situation where I need to define proportions between children of a Component (for example, child 1 should use 10% of space, child 2 40%, child 3 50%), is it possible to achieve that without implementing a custom LayoutManager?</p> </blockquote> <p>Any of the Big-Three can, can't even GridBag (never bothered to really master, too much trouble for too little power).</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload