Results 1 to 2 of 2
  1. #1
    rellicott is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Grid Layout change layout alignment of control s

    I have a window with multiple composites on it. I use several of the composites as place holders that I put a second composite into and then add widgets to them. I dispose of the inner or second composite and rebuild them base on user input. The issue I have is when I rebuild the composite some times I want the controls to align to the left and other times to the right. It seems that what ever the alignment is the first time I build the composite is what I am stuck with even thought I dispose of the composite and rebuild it. I tried changing the alignment on the first (place holder) composite at the same time as the rebuilt composite but that has no effect either. Anyone have any ideas why I can't change the alignment of the composite?


    Sample code

    if (state.commandBtnArea != null)
    state.commandBtnArea.dispose();

    state.commandBtnArea = new Composite(state.reuseCommandBtnArea, SWT.LEFT);
    state.commandBtnArea.setVisible(true);

    GridLayout gl = new GridLayout(8, false);
    gl.marginHeight = 1;
    gl.marginWidth = 0;
    gl.horizontalSpacing = 1;
    state.commandBtnArea.setLayout(gl);

    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.horizontalAlignment = SWT.LEFT;
    gd.verticalAlignment = SWT.CENTER;
    state.reuseCommandBtnArea.setLayoutData(gd);

    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.horizontalAlignment = SWT.LEFT;
    gd.verticalAlignment = SWT.CENTER;
    state.commandBtnArea.setLayoutData(gd);

    Thanks in advance.
    Robert
    Last edited by rellicott; 02-11-2012 at 05:27 AM.

  2. #2
    rellicott is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Re: Grid Layout change layout alignment of control s

    On further review, it is not the alignment that is the problem it is the size of the recreated composite. It seems to always take the packed size of which ever composite was created first. My work around was to add some hidden field to force them to be the same size.

    Robert

Similar Threads

  1. Image into Grid layout
    By Jaxn77 in forum AWT / Swing
    Replies: 6
    Last Post: 02-10-2011, 04:02 PM
  2. Group Layout Alignment
    By Hades82 in forum AWT / Swing
    Replies: 7
    Last Post: 12-30-2010, 12:37 PM
  3. Grid layout frames GUI
    By fritz1474 in forum AWT / Swing
    Replies: 1
    Last Post: 10-15-2008, 03:04 AM
  4. what layout to use for vertical alignment?
    By dim_ath in forum AWT / Swing
    Replies: 6
    Last Post: 01-20-2008, 06:28 PM
  5. Help with Grid Layout
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 09:03 PM

Tags for this Thread

Posting Permissions

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