Can I avoid the state when components unexpectedly moved in container during design of GroupLayout?

Yes, actually you can minimize occurrence of this behavior when you keep the rules listed below.

  1. Have a concept of the designing form. It's better to have a relatively precise idea how the form will look like in advance. It's better to add components on the intended places directly, with the right (suggested) spacing and alignment, rather then throwing them randomly on canvas and then trying to rearrange them.
  2. Design by smaller parts. Try to divide complicated UI into sub-panels when suitable. You can then also switch (focus) design only to these individual panels. The visual design is easier to manage when composed from less complex parts.
  3. Alignment Tools. Image:AlignmentTools_FaqUnexpectComponentMove.png Use alignment tools from the designer toolbar in case when you want to center already placed components, align them along the left/right column etc - instead of rearranging them by mouse one by one.
  4. Guide Lines. Pay attention to the guidelines that appear when dragging components and use them to place/align/anchor components as needed. Snapping at guidelines creates relations between components which are preserved dynamically. Random positioning may lead to unexpected behavior later.
  5. Space Around Components. If you want to do small adjustments like moving components towards each other, which in fact means to adjust the space between components or at the border, use the "Space Around Components" dialog from the popup menu. It's much easier to set the desired space directly than trying to move multiple components manually.
  6. The Same Size Tool. To make several components of the same size, don't try to resize them to match each others size. Instead use the "Same Size" actions from popup menu on selected components.

  Applies to: All NetBeans versions
  Platforms: All
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo