Announcement

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

    Label widget not using 100% width unless I manually resize window

    I have a label buried inside a VLayout that is buried with HLayouts & VLayouts and finally a top-level Window. The label however is not using the full width of the window when the window is first created. However, if I manually resize the window by even 1 pixel, the label automatically adjusts CORRECTLY to use the full width. Is this a known issue? I tried a quick workaround by calling the redraw method, but that didn't help.

    Note: All layouts are set to 100% width. Overflow is set to visible on all components. And the window's autoresize is set to true.

    Additional details:
    ======================
    OS: Windows XP Pro
    IDE: MyEclipse 10.0 with Google Plugin for Eclipse (2.5)
    SmartGWT EE 3.0p
    Browwer: Mozilla Firefox 4.0.1 vs Chrome 20.0.1132.57 m
    GWT SDK: 2.5.0rc1
    Sun JDK 1.6.30

    #2
    Here's a very simple test case iillustrating the problem. If you run it, you'll see that intially, the label "Some test message" will use maybe only 50% of the width of the window. But if you just resize manually by even 1 pixel, then the label will *correctly* end up using 100% of the width. This is a very simple test cases now....

    Code:
    com.smartgwt.client.widgets.Window x = new com.smartgwt.client.widgets.Window();
    x.setAutoSize(true);
    x.setCanDragResize(true);
    VLayout vl = new VLayout();
    Label l1 = new Label("Some test message that is nice and long. xxxxxxxx xxxxxxx xxxxxxxx xxxxxxxx yyyyyyyyyy zzzzzzzz hhhhhhhhhhh iiiiiiiiiii " +
    		" hhhhhhhhhh hhhhhhh hhhhhhhhh hhhhhhh");
    //			Label l2 = new Label("Another test message that is nice and long. xxxxxxxx xxxxxxx xxxxxxxx xxxxxxxx");
    HLayout hlForBtns = new HLayout();
    
    hlForBtns.setMembersMargin(10);
    //hsForBtns.setHeight("8%");
    //    hlForBtns.setHeight("100%");
    hlForBtns.setWidth("100%");
    hlForBtns.setOverflow(Overflow.VISIBLE);
    
    hlForBtns.setAlign(Alignment.CENTER);
    Button btnOk = new Button("Ok");
    hlForBtns.addMember(btnOk);
    Button btnCancel = new Button("Ok");
    hlForBtns.addMember(btnCancel);
    
    vl.addMember(l1);
    vl.addMember(hlForBtns);
    x.addItem(vl);
    x.draw();
    x.show();

    Comment


      #3
      The Window is autoSize: true and none of the other components specify a size. Just give the window a fixed initial width.

      Comment


        #4
        I tried your suggestion, but it didn't make a difference. Just for completeness, here's the new code. (You'll notice on lines 4 and 5 that I'm now setting the width and height to 1 pixel; I also tried setting it to 400 pixels. In all cases, the "label" widget won't use up 100% of the width unless I manually resize the window. I also tried giving the label widget an initial width and height of 1, but that didn't help either.) The code is below, but I have a theory that Isomorphic can perhaps validate:

        If you look at the 1st attached screenshot, you'll see that the window correctly got the right width, as it's based off the width of the 2 buttons. So that's good. But, it did NOT use that width to determine the width of the label. Instead, it just made the label's height very big in order to accomodate all the text. My theory is that the Isomorphic program is not "processing" the windows in the right order: it's not first discovering that the maximum "forced" width is determined by the two buttons, and then ****re-calculcating*** that the label should use that new width before determining the label's length. But, when I manually resize the window, I'm ***"telling"*** the program what width and height to use, all the internal components "know" what width and height that they must work with.


        FYI: The 1st screenshot ("ScreenHunter 07...jpg") is the result of running the code and seeing the initial results; The 2nd screenshot ("ScreenHunter 08...jpg") is what it (correctly) looks like when I manually adjust the width by approximately 1 pixel.

        Code:
        com.smartgwt.client.widgets.Window x = new com.smartgwt.client.widgets.Window();
        x.setAutoSize(true);
        x.setWidth(1);
        x.setHeight(1);
        x.setCanDragResize(true);
        VLayout vl = new VLayout();
        Label l1 = new Label("Some test message that is nice and long. xxxxxxxx xxxxxxx xxxxxxxx xxxxxxxx yyyyyyyyyy zzzzzzzz hhhhhhhhhhh iiiiiiiiiii " +
        		" hhhhhhhhhh hhhhhhh hhhhhhhhh hhhhhhh");
        //l1.setWidth("100%");
        //l1.setHeight(40);
        l1.setOverflow(Overflow.VISIBLE);
        //			Label l2 = new Label("Another test message that is nice and long. xxxxxxxx xxxxxxx xxxxxxxx xxxxxxxx");
        HLayout hlForBtns = new HLayout();
        
        hlForBtns.setMembersMargin(10);
        //hsForBtns.setHeight("8%");
        //    hlForBtns.setHeight("100%");
        hlForBtns.setWidth("100%");
        hlForBtns.setOverflow(Overflow.VISIBLE);
        
        hlForBtns.setAlign(Alignment.CENTER);
        Button btnOk = new Button("Ok");
        hlForBtns.addMember(btnOk);
        Button btnCancel = new Button("Ok");
        hlForBtns.addMember(btnCancel);
        
        vl.addMember(l1);
        vl.addMember(hlForBtns);
        x.addItem(vl);
        x.draw();
        x.show();
        Attached Files

        Comment

        Working...
        X