Results 1 to 3 of 3
  1. #1
    doru.chiulan is offline Member
    Join Date
    Jul 2012
    Posts
    9
    Rep Power
    0

    Default GroupLayout - Spring Gap Issue

    Java Code:
     
    +---------------------------------------------------------------------------+
    |[5] [image=16px] [5] [label1][spring gap max=av_sp,min=5]+[label2] [5]      |
    |                 [5] [label3]                                              |
    +---------------------------------------------------------------------------+
    av_sp = Available Space left to the right margin
    Ok guys i built this group layout, which is a custom cell renderer for my JList.
    I have somehow to compute the available space that is left from label1/label3 to the right margin.

    Java Code:
    GroupLayout cell = new GroupLayout(this);
                setLayout(cell);
                cell.setAutoCreateGaps(true);
                cell.setAutoCreateContainerGaps(true);
                int pPathWidth=(ProjectList.LISTWIDTH-16-20)/2; //that's something i tried, not a solution...
                
                SequentialGroup s1 = cell.createSequentialGroup();
                    cell.setHorizontalGroup(s1);
                        s1.addGap(5);
                        s1.addComponent(pTypeIcon, 16, 16, 16);
                        ParallelGroup p1 = cell.createParallelGroup(GroupLayout.Alignment.LEADING,false);
                        s1.addGap(5);
                        s1.addGroup(p1);
                            p1.addComponent(pName,0,172,172);
                            SequentialGroup s2 = cell.createSequentialGroup();
                            p1.addGroup(s2);
                            //Status icons
                                if (statusLabels != null)
                                    for (int i = 0; i < statusLabels.length; i++)
                                            s2.addComponent(statusLabels[i]);
                                else
                                            s2.addComponent(correct);    
                                s2.addComponent(jSeparator, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
                            //Branch
                                s2.addComponent(branchName);        
                            //Push/Pull    
                                if (ppLabel != null){
                                    s2.addComponent(jSeparator2, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
                                    for (int i = 0; i < ppLabel.length; i++)
                                            s2.addComponent(ppLabel[i]);
                                }
                        s1.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,5, 172); //not good, i was just trying to find a solution
                        int prefWidth = pPath.getPreferredSize().width > 172 ? 230 : pPath.getPreferredSize().width; //not good, i was just trying to find a solution
                        s1.addComponent(pPath,0,prefWidth,250);//not good, i was just trying to find a solution
                        s1.addGap(5);                     
    
                SequentialGroup s11 = cell.createSequentialGroup();
                    cell.setVerticalGroup(s11);
                    s11.addGap(5);
                    ParallelGroup p11 = cell.createParallelGroup(GroupLayout.Alignment.CENTER);
                    s11.addGroup(p11);
                        p11.addComponent(pTypeIcon);
                        p11.addComponent(pName);
                        p11.addComponent(pPath);
    
                    ParallelGroup p22 = cell.createParallelGroup();
                    s11.addGroup(p22);
    
                    //Status icons
                        if (statusLabels != null)
                            for (int i = 0; i < statusLabels.length; i++) 
                    p22.addComponent(statusLabels[i]);
                        else
                    p22.addComponent(correct);
    
                    p22.addComponent(jSeparator);
    
                    //Branch
                    p22.addComponent(branchName);
    
                    //Pulls/pushes
                        if (ppLabel != null) {
                    p22.addComponent(jSeparator2);
                            for (int i = 0; i < ppLabel.length; i++) 
                    p22.addComponent(ppLabel[i]);}
                    s11.addGap(5);
    Last edited by doru.chiulan; 08-10-2012 at 09:43 AM.

  2. #2
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: GroupLayout - Spring Gap Issue

    um, since I do not have the full code and I cannot run this, what is your current issue or question? Are there errors? What glitches have you found? Where does the gap become apparent?
    My API:
    Java Code:
    cat > a.out || cat > main.class

  3. #3
    doru.chiulan is offline Member
    Join Date
    Jul 2012
    Posts
    9
    Rep Power
    0

    Default Re: GroupLayout - Spring Gap Issue

    i will post a picture later
    The problem is that i cannot get the gap as i want(if the label width is less than the space left to the right margin, that gap should push the label to the right, if the label is too long , my scrollable pane should not extend and "cut" last part of the label)

    You will see in the picture what's wrong. Thank you for reply and sorry for my bad question :D.

Similar Threads

  1. session expire issue in spring
    By thirish in forum Web Frameworks
    Replies: 2
    Last Post: 01-07-2012, 11:12 AM
  2. GroupLayout
    By Itun in forum AWT / Swing
    Replies: 3
    Last Post: 03-24-2011, 06:19 PM
  3. GroupLayout Issue
    By m_patten2 in forum AWT / Swing
    Replies: 2
    Last Post: 11-10-2010, 11:50 PM
  4. Spring Configuration Error - XML issue?
    By hofsoc in forum New To Java
    Replies: 0
    Last Post: 09-20-2010, 04:21 PM

Posting Permissions

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