Issue Details (XML | Word | Printable)

Key: DESIGNGRIDLAYOUT-50
Type: Task Task
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: jfpoilpret
Reporter: bobndrew
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
designgridlayout

Describe the limitation for indent() only working with LabelAlignment.LEFT

Created: 08/Dec/11 10:23 AM   Updated: 03/Feb/13 09:43 PM   Resolved: 03/Feb/13 05:42 PM
Component/s: None
Affects Version/s: current
Fix Version/s: None

Time Tracking:
Not Specified

Environment:

Windows 7


Tags: javadoc website indent
Participants: bobndrew and jfpoilpret


 Description  « Hide

I was trying to indent some rows with the layout set to

layout.labelAlignment( LabelAlignment.RIGHT );

The indentation is only working with LEFT alignment.

This should be mentioned in:

In my opinion all examples with strings having the same length could benefit from changing them to 'real world' strings:

  • Example 3: row1, row2, row3 --> first name, surname, birthday
  • Indent-examples: Label 1, Label 2, Label 3 --> Address, Street, City

This would have shown me that the indent example was using LEFT alignment.



jfpoilpret added a comment - 25/Dec/11 10:13 AM

Well, in fact, we cannot really say that indent() works only with left alignment. I'd rather say that it seems to work a bit differently when using right alignment.

The notion of indent is just extra space added on the left of a row, or more precisely, as mentioned in the javadoc, space added before the left most component of a row.

In the case of grids, the labels in the label column (the 1st column of the grid) are, initially, all forced to the same width (the max width of all labels in the column). Then extra space is added when rows are indented.

When you use right-alignment, the indent space most often won't clearly be visible to the end user.

However, there are situations where this indent will appear as expected:

layout.row().left().add(new JLabel("Address"), new JSeparator()).fill();
layout.row().grid(new JLabel("Street 1")).indent(1).add(new JTextField("Benjamin Franklin Bd"));
layout.row().grid(new JLabel("Zip Code")).indent(1).add(new JTextField("CA 1234"));

In the example above, when using right alignment, you will see that "Zip Code" is indented in comparison with "Address". You would see no indent at all when not using indent(1).


bobndrew added a comment - 18/Jan/12 12:18 PM

I thank you for your reply. But I think to add a row out of the canonical grid to get an indent should not be the way to "solve" this for a user of this library.

I think the second line should also be starting at the postion where the first line is starting, if I use this example:

layout.row().left().add( new JLabel( "Out of the canonical grid..." ) );
layout.row().grid( new JLabel( "Label 1:" ) );
layout.row().grid( new JLabel( "Label 2:" ) ).indent( 4 ).add( new JTextField( "field 2" ) );
layout.row().grid( new JLabel( "Label 3:" ) ).indent( 4 ).add( new JTextField( "field 3" ) );

jfpoilpret added a comment - 20/Jan/12 10:09 PM

For me, your last example gives the expected result.
The reason is that there is only ONE canonical grid, and all "grid()" rows belong to it.
Non-canonical grid rows (left, right, center and bar) share no dimension with grid rows and are completely independent of grid rows.
In a canonical grid, there is one specific label column, which size is fixed and equal to the max width of all labels in that column,
plus the max indents added to grid rows.

Hence, in your example, the first column of the first grid row ("Label 1:") is the same width as 1st column of grid rows "Label 2: " and "Label 3:" which are indented 4 times.
Now, since the alignment of labels is right, "Label 1:" will be right-aligned in this column and will thus appear indented, compared with the 1st row, out of the canonical grid.


jfpoilpret added a comment - 20/Jan/12 10:12 PM

Not an improvement to DGL library but rather a task to improve the documentation.
Considered minor, because I don't think many people will see the observed behavior problematic when using indent() with right alignment for labels.


jfpoilpret added a comment - 03/Feb/13 05:42 PM

Documentation updated on SVN trunk (rev. 520).


jfpoilpret added a comment - 03/Feb/13 09:43 PM

Documentation fixed in release 1.10