1. 程式人生 > >nc中限制只能輸入數字

nc中限制只能輸入數字

舉例限制ifloor欄位只能輸入數字

if (e.getKey().equals("ifloor")){
			String ifloor =  (String) e.getBillCardPanel().getHeadItem("ifloor").getValueObject();
			Pattern pattern = Pattern.compile("[0-9]*");
			Matcher isNum = pattern.matcher(ifloor);
			if(!isNum.matches()){
				MessageDialog.showErrorDlg(e.getBillCardPanel(), "提示", "樓層只能輸入數字!");
				e.getBillCardPanel().setHeadItem("ifloor", null);
			}
		}