Hello,
I'm sorry but I cannot get this thing to work, hoping someone can point out my mistake. I want a window with three buttons, and I want a layout with a label on top of them to take up the entire window width. If you take a look at the attached image it should be clear what I'm after and what not is happening...
I have made a simple test case which is the base of the attached screenshot so that you can see what I'm doing.
In short, I'd expect that calling setWidth100() on either the layout or the label would make it take up the entire window width, but clearly that isn't happening. I tried lots of stuff, for example addChild instead - that made it take up the width, but the layout got completely screwed up.
If someone could take a look at the below code and explain why the layout in my popup won't expand to the full window width, I'd be super happy!
I'm sorry but I cannot get this thing to work, hoping someone can point out my mistake. I want a window with three buttons, and I want a layout with a label on top of them to take up the entire window width. If you take a look at the attached image it should be clear what I'm after and what not is happening...
I have made a simple test case which is the base of the attached screenshot so that you can see what I'm doing.
In short, I'd expect that calling setWidth100() on either the layout or the label would make it take up the entire window width, but clearly that isn't happening. I tried lots of stuff, for example addChild instead - that made it take up the width, but the layout got completely screwed up.
If someone could take a look at the below code and explain why the layout in my popup won't expand to the full window width, I'd be super happy!
Code:
public class Test implements EntryPoint { public void onModuleLoad() { VLayout mainLayout = new VLayout(); mainLayout.setBorder("1px solid yellow"); mainLayout.setWidth(500); mainLayout.setHeight(300); mainLayout.setMembersMargin(30); mainLayout.setLayoutTopMargin(20); IButton show = new IButton("popup"); show.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { MyPopup popup = new MyPopup(); popup.show(); } }); mainLayout.addMember(show); mainLayout.draw(); } class MyPopup extends Window { VLayout layout = new VLayout(10); HLayout buttonsLayout = new HLayout(10); MyPopup() { setTitle("Testing testing"); setIsModal(true); setAlign(VerticalAlignment.TOP); setDefaultLayoutAlign(VerticalAlignment.TOP); setShowMinimizeButton(false); setShowModalMask(true); setAutoCenter(true); setCanDragResize(false); setChildrenSnapResizeToGrid(true); setCanDrag(true); setShowCloseButton(true); setShowStatusBar(false); layout.setMargin(20); layout.setWidth100(); layout.setHeight100(); layout.setBorder("1px solid red"); layout.setMembersMargin(10); Label test = new Label("This is a label."); test.setBorder("1 px solid blue"); layout.addMember(test); super.addItem(layout); buttonsLayout.setAutoHeight(); buttonsLayout.setWidth100(); buttonsLayout.setMargin(10); buttonsLayout.setMembersMargin(10); buttonsLayout.setAlign(Alignment.CENTER); IButton b1 = new IButton("First"); IButton b2 = new IButton("Second"); IButton b3 = new IButton("Third"); buttonsLayout.addMember(b1); buttonsLayout.addMember(b2); buttonsLayout.addMember(b3); super.addItem(buttonsLayout); setAutoSize(true); } }
Comment