我有一个包含选择器和其他组件的对话框。我需要它的高度自动修复,最后一个组件结束。在下面的图片中,它应该在提交按钮后结束。
代码:
Dialog selectDialog = new Dialog();
selectDialog.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
selectDialog.getAllStyles().setMargin(0, 0, 0, 0);
Container pickerContainer = new Container(new BorderLayout());
Picker p = new Picker();
p.setStrings(outlets);
Label arrowLabel = new Label(pickerIcon);
arrowLabel.setUIID("Container");
pickerContainer.add(BorderLayout.CENTER, p);
pickerContainer.add(BorderLayout.EAST, arrowLabel);
Label nameLabel = new Label("Name");
Label nameData = new Label("Santosh Kandel");
Label locationLabel = new Label("Location");
Label locationData = new Label("Baneswor");
Label timeLabel = new Label("Time");
Label timeData = new Label("09:47");
Label dateLabel = new Label("Date");
Label dateData = new Label("2017-2-10");
TableLayout dialogTable = new TableLayout(7, 2);
Container attendenceTableContainer = new Container(dialogTable);
attendenceTableContainer.getAllStyles().setMargin(0, 0, 50, 50);
attendenceTableContainer.add(dialogTable.createConstraint().widthPercentage(30), nameLabel)
.add(dialogTable.createConstraint().widthPercentage(70), nameData)
.add(dialogTable.createConstraint().widthPercentage(30), locationLabel)
.add(dialogTable.createConstraint().widthPercentage(70), locationData)
.add(dialogTable.createConstraint().widthPercentage(30), timeLabel)
.add(dialogTable.createConstraint().widthPercentage(70), timeData)
.add(dialogTable.createConstraint().widthPercentage(30), dateLabel)
.add(dialogTable.createConstraint().widthPercentage(70), dateData);
Button submitButton = new Button("Submit");
selectDialog.add(pickerContainer);
selectDialog.add(attendenceTableContainer);
selectDialog.add(FlowLayout.encloseCenter(submitButton));
selectDialog.showAtPosition(200, 200, 50, 50, false);
我尝试了d.showPopupDialog(组件),但它没有将对话框放在我想要的位置。在这里,我希望它在表单的顶部有一些余量,在某些情况下也在特定的位置。谢谢
答案 0 :(得分:1)
您可以使用showStretched或showPacked,具体取决于您是希望Dialog占用屏幕宽度还是调整大小以适应最宽组件的大小,并且您可以定义它应弹出的位置:
selectDialog.setAutoDispose(false);
selectDialog.setDisposeWhenPointerOutOfBounds(true);
selectDialog.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, false, 300));
selectDialog.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 800));
selectDialog.showStretched(BorderLayout.NORTH, true);