Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Layout problems for window with autoSize and labels

    Hi, I tried for an hour to get a simple layout done. This is the code:

    Code:
      
     public class ProgressWindow extends Window {
            ProgressWindow() {
                setTitle("Progress window title");
                setAutoSize(true);
                setBackgroundColor("red");
    
                layout = new VLayout();
                layout.setMembersMargin(10);
                layout.setBackgroundColor("blue");
    
                Label test_label = new Label("Test label with long text");
                test_label.setBackgroundColor("green");
                layout.addMember(test_label);
    
                Label test_label2 = new Label("Test label 2 with even longer text");
                test_label2.setWrap(false);
                test_label2.setBackgroundColor("grey");
                layout.addMember(test_label2);
    
                addMember(layout);
            }
        }
    And this is how it looks like:

    Click image for larger version  Name:	2018-03-20 18_50_32-window_layout.png Views:	1 Size:	2.3 KB ID:	252369
    Now several question I couldn't find answers for in the documentation:
    • Why is the window title abbreviated? How can I set it to use the available space? And how can set the window width to be at least the width the window title requires?
    • How can I make the first label to use the available width? (Without setting wrapping to false. The text is actually dynamic and wrapping should be kept if the width is not sufficient.)
    • What is the white space at the bottom and how can get rid of it?
    • What is the logic behind the total window height and the height of the labels? Is it some kind of constant and where can I find more information about it? I actually want the window height to fit to the content. But this should work by using setAutoHeight() for both labels.



    Thanks! I really tried hard and now I'm a bit frustrated because it should actually be really easy.

    SmartClient Version: v11.1p_2017-07-03/LGPL Development Only (built 2017-07-03)
    Chrome Version 64.0.3282.186
    Last edited by abika; 20 Mar 2018, 10:21.

    #2
    Hi abika,

    1st thing I noticed, use addItem() instead of addMember() at Window-level (your last command). Please repost a screenshot after this change.

    Best regards
    Blama

    Comment


      #3
      Hi Blama , thanks for help! I admit I missed the documentation here. Looks a lot better now:
      Click image for larger version

Name:	2018-03-20 18_50_32-window_layout2.png
Views:	158
Size:	2.5 KB
ID:	252383
      I still would like to have the green label to take the available horizontal space without deactivating word wrap.

      And I still can't find out how the window height is calculated.

      Comment


        #4
        Your Label has no size associated so it has the default width (100). They also have no heights set so they have default height (100).

        The Window is autosizing to these defaults vertically, and to the width of the unwrappable label horizontally.

        If you wanted the other label to match the (dynamic) width of the grey label, one way to do this is to use layout.minBreadthMember - set the grey label as the minBreadthMember.

        Comment


          #5
          Got it finally, thanks! I find it very strange that labels have a default height and width of 100 px expecting this to be overwritten in 99.9% of all usage cases.

          Comment


            #6
            Labels are often used for a block of text such as instructions, so no, nothing like 99.9%.

            Comment

            Working...
            X