Results 1 to 2 of 2
  1. #1
    matthew_be is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Question GroupLayout - problem with alignement

    Hi!

    I can't achieve what I want with GroupLayout.

    This is what is displayed with the code below:
    http://i51.tinypic.com/20jjrjm.jpg

    What I need is to have the button "Envoyer" aligned to the border right of the texfield. The two comboboxes need to stay aligned left to the border of the textfield, so those two don't need to move; I only need to move the button to the right.

    Java Code:
    layout.setHorizontalGroup(
             layout.createSequentialGroup()
                .addComponent(labelPasDeNouveauxPM)
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                   .addComponent(textFieldMessage)
                   .addGroup(layout.createSequentialGroup()
                      .addComponent(comboBoxColor,
                                 GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE)
                      .addComponent(comboBoxFontSize,
                                 GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE,
                                 GroupLayout.PREFERRED_SIZE)
                      .addComponent(buttonEnvoyer)))
       );
     
       layout.setVerticalGroup(
          layout.createSequentialGroup()
             .addComponent(textFieldMessage)
             .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                .addComponent(labelPasDeNouveauxPM)
                .addComponent(comboBoxColor,
                         GroupLayout.PREFERRED_SIZE,
                         GroupLayout.PREFERRED_SIZE,
                         GroupLayout.PREFERRED_SIZE)
                .addComponent(comboBoxFontSize,
                         GroupLayout.PREFERRED_SIZE,
                         GroupLayout.PREFERRED_SIZE,
                         GroupLayout.PREFERRED_SIZE)
                .addComponent(buttonEnvoyer))
       );
    Thank you for any help!

  2. #2
    matthew_be is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default

    Found the answer:
    addPreferredGap(LayoutStyle.ComponentPlacement.REL ATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

Similar Threads

  1. GroupLayout problem
    By batia in forum New To Java
    Replies: 5
    Last Post: 04-27-2011, 08:31 PM
  2. Problem in GroupLayout ?
    By makpandian in forum New To Java
    Replies: 10
    Last Post: 04-18-2011, 09:26 AM
  3. GroupLayout
    By Itun in forum AWT / Swing
    Replies: 3
    Last Post: 03-24-2011, 06:19 PM
  4. Doubt with GroupLayout
    By emylyano3 in forum AWT / Swing
    Replies: 1
    Last Post: 06-28-2009, 03:16 AM
  5. "Problem With GroupLayout", Please Help !
    By adeeb in forum AWT / Swing
    Replies: 1
    Last Post: 06-04-2008, 11:29 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
  •