Right alignment with SpringLayout

I've just started playing with SpringLayout. I've been using mostly BoxLayout up to now but I thought it was time I gave an alternative a go. BoxLayout has it's own erratic sizing problems.
Anyway I'm trying to generate a sub panel like:
Title (centered)
Quantity1 888
Quantity2 99
<Table> <PieChart>
With the numbers against the RHS of the box
First thing I've found is that putting a zero length Spring between the NORTH of the lable and the value doesn't work, I have to set both relative to the previous line or (mysteriously) no vertical separation happens at all.
Here's the code that adds a lable/value pair:
    private static Component addPair(Component prev, String label, JLabel value) {
        Container c = prev.getParent();
        SpringLayout l = (SpringLayout)c.getLayout();
        JLabel nameLab  = new JLabel(label);
        c.add(nameLab);
        c.add(value);
        l.getConstraints(nameLab).setHeight(Spring.constant(12));
        l.putConstraint(SpringLayout.NORTH, nameLab, 2, SpringLayout.SOUTH, prev);
        l.putConstraint(SpringLayout.WEST, nameLab, 10, SpringLayout.WEST, c);
        l.putConstraint(SpringLayout.EAST, c, 10, SpringLayout.EAST, value);
        l.putConstraint(SpringLayout.NORTH, value, 2, SpringLayout.SOUTH, prev);
     //   l.putConstraint(SpringLayout.SOUTH, nameLab, 0, SpringLayout.SOUTH, value);
        l.putConstraint(SpringLayout.WEST, value, Spring.constant(10, 10, 500),
                SpringLayout.EAST, nameLab);
        return nameLab;
    }prev being the label from the previous pair.
It refuses to right align the value lable. It looks like the constraint between the EAST of the value and the EAST of the container has no effect. I've also set the alignment in the JLabels to RIGHT, which has no effect.
If I take out the constraint between the WEST of the value and the EAST of the lable It plonks the lable and value on top of one another.
Furthermore, though the hieght of the pie chart is set explictly by a constraint, the LayoutManager seems incapable of producing a sensible minimum height for the overall box.
All of which makes me wonder if SpringLayout is worth persevering with or if there are just tricks and gaps I have to learn to deal with.

I think I've cracked it. Some things they don't tell you about SpringLayout, which I found out mostly by reading the source.
putConstraint is not symetrical. Logically
putConstraint(SpringLayout.WEST, container, 10, SpringLayout.WEST,
valueLab);might be expected to imply:
putConstraint(SpringLayout.WEST, valueLab, -10,  SpringLayout.WEST,
container);But it doesn't. Only the first object in the call is actually constrained.
Secondly the "overconstraint" thing is very arbitary. Setting the NORTH or WEST clears the EAST or SOUTH wherease setting the EAST or SOUTH clears the height or width. Hence if you set, for example, EAST and WEST then it's essential to set EAST first, otherwise WEST will be ignored and the WEST will be set from EAST - width. There seems to be no way of clearing a constraint once set, and constraints are intialised from the objects bounds, so NORTH and WEST are always set to zero initially. If seems like the contraints are almost always going to be treated as overconstrained.
Parallel constraints don't get combined, the last one specified predominates so there doesn't seem any sensible way of, for example, setting the width of a container based on the maximum of the widths of fields contained.
There seems to be no use of the springiness of Spring objects. They are merely treated as min, pref and max values. Logically stretchiness should be used to distribute space, and to cope with springs in parallel. It doesn't appear any of that stuff is done.

Similar Messages

  • Right alignment with in navigation panel.....

    Hi, I am new to JSF. I am using this tag, i want the text to be right aligned with in this navigation panel.
    But, it is not working. Please guide me to align the text on right hand side.
    I am using JSF 1.2 version and Tomcat 6.0
    <t:panelNavigation2 align="right">Please help me.
    Regards,
    ash

    Use CSS along with the styleClass and/or style attributes.

  • Right align with left leading zeores

    Hi,
    I have a material no in sap and i have download this in text file
    My requirement is I need to align material no in right, with left leading zeores
    What is the syntax for this

    Hello
    Syntax for this:
    Read RULES: <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="927634"></a>

  • Right Align Dropdown Menu

    I'm working on my mobile site and have a dropdown box on the right edge of the screen. I can't figure out how to get it so the dropdown boxes are right-aligned with the edge of the box. At the moment they are left aligned, which means the menu items disappear off the right edge of the screen. Am I missing something or is this not possible?

    Could you post your Screenshot and code.
    There is "browse" icon above POST REPLY button, it helps to add your image.

  • Right align page numbers that are to the left of TOC entries

    I posted a similar question about a year ago that I believe Harbs or Peter answered, but darned if I can find the thread. At that time they provided a script that did a GREP search, finding a sentence that starts with a digit and replacing it with a tab. I still have the script, but for some reason it is not working correctly with my new TOC layout.It should insert a tab to the left of the page number (page numbers are to the left of the TOC entries), and force the numbers to right align so that a single digit page number right aligns with the right edge of a double-digit page number.
    Find: ^(\d+)
    Change to: \t$1
    What happens in the new TOC is the script finds a digit and inserts a tab to the left of the page number. The page numbers move to the right, but they don't right align. They are further to the right, but they numbers themselves are still left aligned.
    I'm mystified as to why the script doesn't work on this new layout. I'm using CS4 now, and it still works on the old layout. There is nothing terribly different about the new layout except that the column is much narrower, and there are several threaded colums in the TOC instead of one long column, and the chapter titles don't have page numbers (but all other entries do have page numbers.)

    Peter,
    Thanks for your reply. Between the page number and the entry is an en-space.
    I started with these settings:
    I then changed the left aligned tab to a right aligned tab:
    But still no luck.

  • Issue with right aligning of Character Styles in my TOC

    Hello all!
    I'm working on my very first book project and I have been reading soooo many threads on here for the past hour, but i either just don't get it, or i didn't find what i needed still, so i already apologize in case this very question has been answered before ...
    ok, so ... i am building my TOC and have set up the corresponding TOC styles to the paragraph styles used throughout the book.
    what i want is for the page number to appear before the entry. so for the page number i have set up it's own TOC page number character style.
    NOW
    the page number appears left aligned. I have checked the character styles palette and there i can't set a tab for the page number to appear right aligned ...
    how do i get this page number to be right aligned? and THEN, how do i specify the distance between the page number and the entry? there is "tab character"mentioned on the TOC dialogue box to specify the distance between page number and entry, but then do i have to go in manually every time something changes? that can't be it? i have seen in the paragraphy styles palette there is a tab section ... tried to input the tabs so the number would appear right aligned and the distance to the entry, but nothing happened, then the number is stuck right on the entry once the TOC is generated ...
    does this make any sense?
    will attach a screenshot to try to clarify the issue ...
    hope you can help me out.
    thanks a lot in advance!
    cheers
    sta-cy

    sta-cy wrote:
    sorry to have bugged you.
    Seriously, if we didn't enjoy this stuff we wouln't be here. It's not like we even get T-shirts. :-P
    An awful lot of what I know and am able to pass on comes from having spent waaaaay to much time here reading about odd problems and trying to figure out ways to solve them. I'd never seen a requst like yours until the other day, but then up pops Joel with a similar story, and what do you know, this may not be such a strange thing to want at all. Hopefully your question, and the work we put into trying to find an answer, has not only helped you, but some other users who come along next week or next year.
    Everybody starts someplace and at some point in time. There's no shame in being a beginner, and less in asking for help when you need it, especially after you put in the effort you did on your own to try to find a solution. It's also true that some folks are more design oriented and others more process oriented, and that's just the way it is. This forum has many, many, followers who are expert in different areas of InDesign (even the engineers who write the program are not experts in all the various parts) and are here to share what they know as volunteers. You are always welcome here, especially when the question is as intersting as this one.

  • Problem with formatting text in textobjects with right aligned tabulators

    Post Author: Jens Kluesener
    CA Forum: General
    HiI want to print out some values in a line. So I put a Textobject in the Report with some right aligned tabulators (left aligned tabulators working fine). Then I insert a formula. In this formula i do this:"1"chr(9)"2"chr(9)"3"chr(9)"4"chr(9)"5"chr(9)"6"chr(9)"7"Look:            Many ThanksJens

    I think i found why.
    There was no problem with TextField.
    There was a problem with Array. "CityArea"
    So each time I executed script it added new string in Array. And that is because i got like:
    TextField
    City 1
    City 2
    City 1
    City 2
    Running this script is Ok:
    for (var i1:int = 0; i1 < CityArea.length; i1++)
      _CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='32' COLOR='#ffffff'>        "+CityArea[i1]+"</FONT></P>";
      _CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='5' COLOR='#ffffff'><BR></FONT></P>";
    But outside of this for loop there is another for loop for adding Cities in CityArray.
    I fixed it by adding empty array at the start of function
    function myFunc():void
    CityArea = [ ]; // Empty array fixed this issue
    // LOOP FOR ADDING SHOPS IN CITY AREA
    for (var j:int = 0; j < _Shops; j++)
    CityArea.push(_Shop);
    // FOR LOOP TO ADDING SHOPS IN STRING
    for (var i1:int = 0; i1 < CityArea.length; i1++)
      _CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='32' COLOR='#ffffff'>        "+CityArea[i1]+"</FONT></P>";
      _CityAreaString1 += "<P ALIGN='LEFT'><FONT FACE='Verdana' SIZE='5' COLOR='#ffffff'><BR></FONT></P>";
    Thank you for your help kglad

  • XML Import is left aligning my right alignment style with an override, how do I force it to left?

    I'm importing an XML file, using the Import XML menu item, using InDesign CS4.
    In the document I've got a table, with an XML structure in the structure tree, matching in the incoming file. Everything works fine, except that after the 4 "template rows" that I've set up Indesign adds new rows automatically, and for all InDesign auto added rows, InDesign is not using the right alignment that I've set up in the paragraph style applied to the first rows... The style is kept, but overridden by a flush left. (Why?)
    How do I deal with this? I need the right column to go on right aligning
    Best regards, Andreas

    Map tags to styles took care of the problem.

  • Column's Right Alignment goes out with CR in format Mask like NNN,NN0.00CR

    I am working in Reports 6i. For a numeric calculated column, I give format mask NNNN,NNN,NNN,NN0.00CR. Due to CR, right alignment of the column goes out. That is rows for which CR is NOT printer are also aligned at right. A blank space should be left at the end of every row when no CR is printer. In this way numeric data is right aligned and readability is not disturbed.
    Pl. help.
    Thanks in anticipation.

    I am working in Reports 6i. For a numeric calculated column, I give format mask NNNN,NNN,NNN,NN0.00CR. Due to CR, right alignment of the column goes out. That is rows for which CR is NOT printer are also aligned at right. A blank space should be left at the end of every row when no CR is printer. In this way numeric data is right aligned and readability is not disturbed.
    Pl. help.
    Thanks in anticipation.
    Muhammad,
    I tried this on 6.0.8.14.2 version of Reports 6i and it aligned properly (i.e., spaces where present for those values without CR). I originally had the Arial font which as you know is not a fixed font and in this case, the spacing was not exact. I switched to Courier and the output was much more readable for the numeric values, especially with the spacing.
    Regards,
    Jim Safcik
    Thanks Jim Safcik. I changed the font of that column to Courier and it resolved the problem. But I am using Times New Roman font which creates above alignment problem.
    It would be nice if we have an other solution which is NOT font dependent.
    However I appreciate your guidance and knowledge.
    Pl. guide.
    Thanks.

  • How to Right Align the output of amount with currency?

    Hi,
    I have the following SQL query, which basically is the duplication of the SAP standard Item List.  The only difference is, the stock on hand is only for Warehouse 01.
    In the output, I manage to display eg: AUD 1321.00.  However, it is aligned to the center.  Is there a way that I can make it right align like the standard report?  Appreciate your help.
    SELECT T0.[ItemCode], T0.[ItemName], (select T100.OnHand from OITW T100 where T100.ItemCode=T0.ItemCode and T100.WhsCode='01') as 'InStock',T0.[CodeBars], T1.[ItmsGrpNam], T2.[FirmName], T0.[InvntryUom],
    ('AUD'+ replicate(' ',16-len(T0.[LstEvlPric])) + Convert (char(18),(cast ((round(T0.[LstEvlPric], 2)) as decimal(16,2))))  ) as 'Last Eval Price', (T0.[LastPurCur]+ replicate(' ',16-len(T0.[LastPurPrc])) + Convert (char(18),(cast ((round(T0.[LastPurPrc], 2)) as decimal(16,2))))  ) as 'Last Pur. Price',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=1 and T200.ItemCode=T0.ItemCode) as 'L 1',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=2 and T200.ItemCode=T0.ItemCode) as 'L 2',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=3 and T200.ItemCode=T0.ItemCode) as 'L 3',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=4 and T200.ItemCode=T0.ItemCode) as 'L 4',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=5 and T200.ItemCode=T0.ItemCode) as 'L 5',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=6 and T200.ItemCode=T0.ItemCode) as 'Price List 6',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=7 and T200.ItemCode=T0.ItemCode) as 'Price List 7',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=8 and T200.ItemCode=T0.ItemCode) as 'Price List 8',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=9 and T200.ItemCode=T0.ItemCode) as 'Price List 9',
    (SELECT T200.[Currency] + replicate(' ',16-len(T200.Price)) + Convert (char(18),(cast ((round(T200.[Price], 2)) as decimal(16,2)))) FROM ITM1 T200  INNER JOIN OPLN T201 ON T200.PriceList = T201.ListNum where T200.PriceList=10 and T200.ItemCode=T0.ItemCode) as 'Price List 10'
    FROM OITM T0  INNER JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN OMRC T2 ON T0.FirmCode = T2.FirmCode

    Thanks. 
    But, does that mean the the right alignment in SAP Item list was done through UI? 
    Another question is:
    Normally, in an SAP query, when click Ctrl + left click the mouse at the bottom, I can see the total.
    However, with the query that I have created, it seems to cut off the first number.  Eg: The total should be AUD 231,123.00, but it is showing me AUD 31,123.
    Can you see how I can fix that?

  • Bulleted text with a right-aligned tab with a line leader...

    I am using Pages '09 and am trying to have a tabbed line after bulleted text. I can do this in Word '11...set a right-aligned tab with a line leader then tab at the end of the text and it adds a line. When I tab after text in Pages, it indents the bullet.

    Do two paragraph breaks and then delete the lat one. Now you can do the  tabbed line

  • Filling string with right alignment

    I want to fill the String(amount) in right alignment.
    i have 6 places(column) to fill the amont(digit).
    Sometimes it may be of 2 charactersor 3 characters
    24
    234
    256788
    So, I have to read string from right and fill it also starting from right.
    Is there any method for this in java?
    Please suggest

    Thanks Sir,
    formatter.format() works fine.
    But,In my problem;
    I have a row of type char[] having 80 columns.
    I have to fill all amont in 60-65 th column.
    So, I have to put the rightmost String amount in 65th position and fill it accordingly..
    Is there any method like System.arraycopy() ;which works for left starting position and lenth of String.

  • ICal Week view, Date is not aligned with the Time(schedule) of each date

    Well, just like it says over there (`` ). I've recently been to China for a business trip, and I suppose the different time zone may have had something to do with the problem. Now I'm back home, changed the time zone back to normal, still the iCal shows in the weekly view that the Date on the above is not aligning with the Time and schedule. Any suggetions would be grateful!!!

    Hi,
    i omit the scheduling maergin key in material master,
    the result of MRP is
    BASIC DATES
    Finish 15.10.2009
    Start 14.10.2009
    PRODUCTION DATES
    15.02.2010 14:33:25
    14.10.2009 07:00:00
    scheduling type i planned order is still "backwards"
    so in MD04 it is say that the goods is available at 15.10.2009 same with requirement dates.
    this seem not right.
    it seems that order finish date is not adjusted by lead time scheduling on "today scheduling".
    Is there a way so order finish date is adjusted by lead time scheduling on "today scheduling" ????
    Best regards,
    Freddy Ha
    Edited by: Freddy Halim on Oct 14, 2009 10:01 AM

  • Right Align the Currency values in ALV report

    Hi Friends,
    I have developed a report and displayed the output using the ALV. I have columns for currency values in the output table.
    The fields for currency values are character fields. The values in the table for display, is properly right aligned (default for currency values). But in the output, the currency values are left aligned.
    Since I need blank lines in the output table after each entry, I have used the character fields in the output table so that I can clear them and append it to get the blank line.
    Please suggest me to get the currency values right aligned.
    Thanks in advance.

    try with this field in field catalog.
             just(1)        type c,        " (R)ight (L)eft (C)ent.
    for the currency field add this field too in field catalog. it will work.

  • Table numbers in a column to Right alignment

    Hi All,
    I have a table like the below.
    Age (Years)
    1985
    1998
    2007
    1–4
    52
    35
    29
    5–14
    26
    20
    15
    15–24
    102
    82
    80
    25–44
    167
    161
    144
    45–64
    875
    680
    661
    65–74
    2,848
    2,495
    2,059
    75–84
    6,399
    5,703
    5,164
    Over 85
    15,224
    15,111
    12,947
    I want to decimal align the 2nd,3rd,4th column using javascript.
    Paginators are manullay using tab stops and adjusting the "Align to Decimal Tab"
    But I want to do it in javascript
    Help me...

    Hi, Maheshwara:
      Your question's a bit confusing, because your example does not show any decimal points! Perhaps it would be good for you to show a screenshot from InDesign with Hidden Characters enabled and the Tab ruler visible so we can see what is going on.
    What do you want to do, though? My guess is you want to right-align the text, then go through and find the entry with the most characters to the right of a decimal point and set a decimal tab based on that entry, and apply it to the entire column. Sounds pretty easy!
    Are you stuck? What's the problem? How far have you gotten? Do you know Javascript?

Maybe you are looking for