Results 1 to 9 of 9
  1. #1
    nanou is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default [SOLVED] Alignment in GroupLayout

    Hi,

    I'm using a GroupLayout. I have some problems to align components.
    For example in my first panel:
    - label nammed "Ignorer la première ligne" with radio button
    - it's the same whith the label called "Ignorer la dernière ligne" and its radio button

    In the third panel:
    - I think that gaps in this panel are bigger than in the others because of the placement of checkboxes. I would place them a little more up (I tried with LEADING alignment but may be I use it not correctly).

    In order to understand my problem, I give you a file in attachment wich represent my graphic user interface.

    Code of my first panel:
    Java Code:
    layout.setHorizontalGroup(
                layout.createSequentialGroup()
                    .addGap(10)
                    .addGroup(layout.createParallelGroup()                  
                        .addComponent(lbl_traitement)
                        .addComponent(labelSave)
                        .addComponent(labelSep)
                        .addComponent(ligne_1er)
                        .addComponent(ligne_der)
                        .addComponent(label_ligne))
                    .addGap(10)
                    .addGroup(layout.createParallelGroup()
                        .addComponent(traitement)
                        .addComponent(fichierSave)
                        .addComponent(sep)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup()
                                .addComponent(br_oui_bg1))
                            .addGroup(layout.createParallelGroup()
                                .addComponent(br_non_bg1)))                    
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup()
                                .addComponent(br_oui_bg2))
                            .addGroup(layout.createParallelGroup()
                                .addComponent(br_non_bg2)))
                        .addComponent(nb_ligne))
                    .addGap(10)
                    .addGroup(layout.createParallelGroup()
                        .addComponent(boutonParcourir))
                    .addGap(10)
            );
            layout.setVerticalGroup(
                layout.createSequentialGroup()
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(lbl_traitement)
                        .addComponent(traitement))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(labelSave)
                        .addComponent(fichierSave)
                        .addComponent(boutonParcourir))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(labelSep)
                        .addComponent(sep))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(ligne_1er)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(br_oui_bg1)
                                .addComponent(br_non_bg1))))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(ligne_der)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(br_oui_bg2)
                                .addComponent(br_non_bg2))))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label_ligne)
                        .addComponent(nb_ligne))
                    .addGap(5)
            );
    Code of my third panel:
    Java Code:
    layout.setHorizontalGroup(
                layout.createSequentialGroup()
                    .addGap(10)
                    .addGroup(layout.createParallelGroup()
                        .addComponent(lbl_taxo)
                        .addComponent(lbl_arrete)
                        .addComponent(lbl_entite)
                        .addComponent(lbl_perimetre))
                    .addGap(10)
                    .addGroup(layout.createParallelGroup()//GroupLayout.Alignment.LEADING)
                        .addComponent(col_a_affecter)
                        .addComponent(combo_taxo)
                        .addComponent(combo_arrete)
                        .addComponent(combo_entite)
                        .addComponent(combo_perimetre))
                    .addGap(10)
                    .addGroup(layout.createParallelGroup()//GroupLayout.Alignment.LEADING)
                        .addComponent(cb_taxo)
                        .addComponent(cb_arrete)
                        .addComponent(cb_entite)
                        .addComponent(cb_perimetre))
                    .addGap(10)
                    .addGroup(layout.createParallelGroup()//GroupLayout.Alignment.LEADING)
                        .addComponent(this.col_a_preciser)
                        .addComponent(combo_val_taxo)
                        .addComponent(combo_val_arrete)
                        .addComponent(combo_val_entite)
                        .addComponent(combo_val_perimetre))
                    .addGap(10)
            );
            layout.setVerticalGroup(
                layout.createSequentialGroup()
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(col_a_affecter)
                        .addComponent(col_a_preciser))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(lbl_taxo)
                        .addComponent(combo_taxo)
                        .addComponent(cb_taxo)
                        .addComponent(combo_val_taxo))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(lbl_arrete)
                        .addComponent(combo_arrete)
                        .addComponent(cb_arrete)
                        .addComponent(combo_val_arrete))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(lbl_entite)
                        .addComponent(combo_entite)
                        .addComponent(cb_entite)
                        .addComponent(combo_val_entite))
                    .addGap(5)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(lbl_perimetre)
                        .addComponent(combo_perimetre)
                        .addComponent(cb_perimetre)
                        .addComponent(combo_val_perimetre))
                    .addGap(5)
            );
    Moreover I want that the 3 panel have the same height.
    I tried with this code, but it doesn't work:
    Java Code:
    this.pack();
    int height = this.p_fichier.getHeight();
    this.p_elements_obl.setSize(this.p_elements_obl.getWidth(), height);
    this.p_elements_fac.setSize(this.p_elements_fac.getWidth(), height);
    this.validate();
    If you have any idea ???

    Thanks in advance,
    Regards.

    Yannick
    Attached Thumbnails Attached Thumbnails [SOLVED] Alignment in GroupLayout-dev.jpg  
    Last edited by nanou; 04-29-2008 at 04:42 PM.

  2. #2
    nanou is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default

    My problem on the third panel is resolved : I resize checkbox and it works perfecly.

    But I still get the problem with the alignment between a label and two radio buttons :
    the baseline of my label is not the same baseline of the two radio buttons.

    Please help...

    Thanks.

  3. #3
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    Why do you use a program to make your GUI it makes your code unreadable. I know its easier, but is easier always the best way to do things, especially in a field such a computer science.
    My IP address is 127.0.0.1

  4. #4
    nanou is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default

    Hi,

    Why do you use a program to make your GUI...
    Why do you say that? I write this code with my hand, not with a program. To my mind it's not so difficult to understand this code...

    Regards

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    He says that, easy to work with a Java IDE. Yes rather working by hand, it is easy to work on a IDE pal. You have to make a minimal effort to do it.

  6. #6
    nanou is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default

    Hi,

    ok thanks.

    I've found my error in 1st panel -> inside the verticalGroup

    this code :
    Java Code:
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(ligne_1er)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(br_oui_bg1)
                                .addComponent(br_non_bg1))))
    .addGap(5)
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(ligne_der)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(br_oui_bg2)
                                .addComponent(br_non_bg2))))
    becomes
    Java Code:
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(ligne_1er)
                        .addComponent(br_oui_bg1)
                        .addComponent(br_non_bg1))
    .addGap(5)
    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(ligne_der)
                        .addComponent(br_oui_bg2)
                        .addComponent(br_non_bg2))
    ...

  7. #7
    nanou is offline Member
    Join Date
    Apr 2008
    Posts
    5
    Rep Power
    0

    Default

    Hi,

    how to say that my problem is solved?

    Thanks

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    It's a nice work pal, make the correction by yourself. At the same time it's nice to see that you want to mark it as solved. :)

    On top of the thread, you can find a link Thread Tools. Click it, and there you an see Mark this thread as solved. Just click on it and see what happened.

  9. #9
    BobL is offline Member
    Join Date
    Sep 2008
    Posts
    1
    Rep Power
    0

    Default

    Quote Originally Posted by Zosden View Post
    Why do you use a program to make your GUI it makes your code unreadable. I know its easier, but is easier always the best way to do things, especially in a field such a computer science.
    Just help the guy. In business I'd pay peopl to be productve. Hand jamming code is not productive.

    Ok I said my piece. After 5PM we are all Irish. :)

    Have a great Navy day!

Similar Threads

  1. Alignment Issue...
    By chanduseec in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 09-30-2008, 06:47 AM
  2. [SOLVED] alignment problem
    By nanimtech in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 04-10-2008, 01:23 PM
  3. what layout to use for vertical alignment?
    By dim_ath in forum AWT / Swing
    Replies: 6
    Last Post: 01-20-2008, 05:28 PM
  4. alignment of textfield in awt
    By nitinborge5 in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 11:16 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
  •