I have a simple window running but am unable to right-align the buttons. No matter what I do, they align to the left. Here's my code:
Any suggestions?
Code:
// Create and format the window.
final Window winSystem = new Window();
winSystem.setWidth(300);
winSystem.setHeight(200);
winSystem.setShowMinimizeButton(false);
winSystem.setIsModal(true);
winSystem.setShowModalMask(true);
winSystem.centerInPage();
// Create the form to go on the window.
final DynamicForm form = new DynamicForm();
form.setHeight100();
form.setWidth100();
form.setPadding(5);
form.setLayoutAlign(VerticalAlignment.BOTTOM);
form.setDataSource(SystemListGridDataSource.getInstance());
// Add the text items for the form.
TextItem textName = new TextItem("Name");
textName.setTitle("Name");
textName.setSelectOnFocus(true);
textName.setWrapTitle(false);
textName.setLength(128);
TextItem textComment = new TextItem("Comment");
textComment.setTitle("Comment");
textComment.setSelectOnFocus(true);
textComment.setWrapTitle(false);
textComment.setLength(128);
// Add all the fields to the form.
form.setFields(textName,
textComment);
// Create a layout and add the form to it.
VLayout vLayout = new VLayout();
vLayout.setAlign(Alignment.RIGHT);
vLayout.addMember(form);
// Create the cancel button.
Button buttonCancel = new Button("Cancel");
buttonCancel.setLayoutAlign(Alignment.RIGHT);
buttonCancel.addClickHandler(new ClickHandler()
{
public void onClick(ClickEvent event)
{
winSystem.destroy();
}
});
// Create the OK button.
Button buttonOK = new Button("OK");
buttonOK.setLayoutAlign(Alignment.RIGHT);
buttonOK.addClickHandler(new ClickHandler()
{
public void onClick(ClickEvent event)
{
if (form.validate())
{
form.saveData();
winSystem.destroy();
}
}
});
// Create a layout to hold the buttons.
HLayout buttonLayout = new HLayout();
buttonLayout.setLayoutAlign(Alignment.RIGHT);
buttonLayout.addMember(buttonOK);
buttonLayout.addMember(buttonCancel);
// Add the button layout to the layout and then add the layout to the
// window.
vLayout.addMember(buttonLayout);
winSystem.addItem(vLayout);
winSystem.show();
Comment