我不想問這個(gè)簡單的問題,但我正在浪費(fèi)時(shí)間,我想完成它..businesAddressFields.get(TELEPHONE).addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent arg0) { String telephones[] = businesAddressFields.get(TELEPHONE).getText().split(Pattern.quote(" OR ")); for (String telephone : telephones) { if (telephone.length()>0) { if (!telephone.matches(TELEPHONE_PATTERN)) { showMessage("Fehler: Telephonnummer: " + telephone + " ist nicht gültig!/nMeherer Adressen mit ' OR ' trennen.", JOptionPane.ERROR_MESSAGE); businesAddressFields.get(TELEPHONE).requestFocusInWindow(); } } } @Override public void focusGained(FocusEvent e) { // TODO Auto-generated method stub }});我想刪除 forString (telephone:telephones)并且我只需要讓它成為電話,因?yàn)槲覜]有陣列。我想刪除 Patter “OR”,因?yàn)槲抑挥幸粋€(gè)電話號(hào)碼。有人可以幫我舉例或?yàn)槲揖庉嫶a,我將非常感激..
1 回答

波斯汪
TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超4個(gè)贊
修改您的代碼如下:
public void focusLost(FocusEvent arg0) {
String telephone = businesAddressFields.get(TELEPHONE).getText());
if (telephone.length()>0) {
if (!telephone.matches(TELEPHONE_PATTERN)) {
showMessage("Fehler: Telephonnummer: " + telephone + " ist nicht gültig!/nMeherer Adressen mit ' OR ' trennen.", JOptionPane.ERROR_MESSAGE);
businesAddressFields.get(TELEPHONE).requestFocusInWindow();
}
}
}
添加回答
舉報(bào)
0/150
提交
取消