JFace InputDialog
运行效果如图:


代码如下:
IAction updateOrder = new Action("设置顺序") {
public void run() {
InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "设置Order顺序,小数在前", "请输入正整数",
"1", new IInputValidator() {
@Override
public String isValid(String input) {
try {
int i = Integer.parseInt(input);
if (i <= 0) {
return "数值必须>0";
}
} catch (NumberFormatException x) {
return "输入不是数字," + x.getMessage();
}
return null;
}
});
if (dlg.open() == Window.OK) {
// User clicked OK; update the label with the input
System.out.println(dlg.getValue());
}
}
};
本文来自博客园,作者:margo,转载请注明原文链接:https://www.cnblogs.com/ZMargo/articles/13304728.html

浙公网安备 33010602011771号