DocumentFilter for negative and positive integer
问题 I know this is a common question, but I'm trying to create a TextField that only accept int numbers, and it's almost done, here's the code: Create textfield: nome = new JFormattedTextField(); nome.setHorizontalAlignment(SwingConstants.CENTER); nome.setColumns(2); DocumentFilter filtro = new FiltroNumero(); ((AbstractDocument) nome.getDocument()).setDocumentFilter(filtro); panel.add(nome); DocummentFilter: public class FiltroNumero extends DocumentFilter{ public void insertString