Non sò come funzioni GWT ma in swing io faccio cosi:
(questo vale solo per accettare i numeri ma puoi modificarlo a tuo piacimento in modo da accettare quello che vuoi)
Codice:
import javax.swing.text.*;
public class TextLimitDocument extends PlainDocument {
@Override
public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException {
if (str == null)
return;
if (!str.matches("[0-9]*"))
return;
super.insertString(offset, str, attr);
}
}
E poi nel textfield faccio:
Codice:
JTextField text = new JTextField();
text.setDocument(new TextLimitDocument());
Basta che modifichi la scritta in rosso con una regEx che matchi numeri in esadecimale