Results 1 to 6 of 6
  1. #1
    incredibleX is offline Member
    Join Date
    Nov 2013
    Posts
    30
    Rep Power
    0

    Default Handel Group Layout

    How to handle Group Layout Manually without using Layout manager.

    I'm dealing with this piece of code
    how to set sizes, locations etc manually i'm new to these layouts.


    GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
    jPanel2Layout.createParallelGroup(GroupLayout.Alig nment.LEADING)
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(jPanel2Layout.createParallelGroup(GroupL ayout.Alignment.LEADING)
    .addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
    .addComponent(Add)
    .addGap(54, 54, 54))
    .addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
    .addComponent(search)
    .addGap(24, 24, 24))
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addComponent(Info)
    .addPreferredGap(LayoutStyle.ComponentPlacement.RE LATED, 89, Short.MAX_VALUE))
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addComponent(Locate)
    .addPreferredGap(LayoutStyle.ComponentPlacement.RE LATED, 99, GroupLayout.PREFERRED_SIZE))
    .addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
    .addGap(28, 28, 28)
    .addComponent(Add, GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
    .addGap(14, 14, 14))
    .addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
    .addGap(28, 28, 28)
    .addComponent(search, GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE))
    .addGroup(jPanel2Layout.createSequentialGroup()
    .addComponent(view)
    .addPreferredGap(LayoutStyle.ComponentPlacement.RE LATED, 89, Short.MAX_VALUE))
    .addGroup(GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
    .addGroup(jPanel2Layout.createParallelGroup(GroupL ayout.Alignment.LEADING)
    .addComponent(Of)
    .addComponent(On))
    .addGap(31, 31, 31)))
    .addContainerGap())
    );

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,533
    Rep Power
    5

    Default Re: Handel Group Layout

    When I see code like this my eyes glaze over. It looks like something generated by a visual designer. I would recommend that you
    stick with the layout managers. In some managers like GridBagLayout you may specify gaps to tweak the layout but the placement in the frame
    is done by the manager. The Oracle tutorials in my signature cover layout managers in depth with some good examples.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,900
    Rep Power
    5

    Default Re: Handel Group Layout

    It is, GroupLayout was first created as part of Netbeans' visual editor if I recall correctly and was then later introduced into the standard API. It IS a layout specifically designed to facilitate visual designer tools, not really for manually programming a GUI.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    incredibleX is offline Member
    Join Date
    Nov 2013
    Posts
    30
    Rep Power
    0

    Default Re: Handel Group Layout

    so what are the alternatives for this in manual programming

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,900
    Rep Power
    5

    Default Re: Handel Group Layout

    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,328
    Rep Power
    25

    Default Re: Handel Group Layout

    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. group layout designing dynamically
    By amyyadav0 in forum AWT / Swing
    Replies: 1
    Last Post: 06-28-2012, 08:50 PM
  2. Grid Layout change layout alignment of control s
    By rellicott in forum SWT / JFace
    Replies: 1
    Last Post: 02-13-2012, 05:11 PM
  3. Group Layout Alignment
    By Hades82 in forum AWT / Swing
    Replies: 7
    Last Post: 12-30-2010, 11:37 AM
  4. Replies: 4
    Last Post: 08-05-2010, 08:08 AM
  5. group layout - span ?
    By random7 in forum AWT / Swing
    Replies: 4
    Last Post: 07-26-2010, 09:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •