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());
					}
				}
			};

  

 

posted @ 2020-07-15 11:54  margo  阅读(143)  评论(0)    收藏  举报