Java tutorial
//package com.java2s; import java.awt.Color; import javax.swing.JTextField; public class Main { public static boolean verifyIntegerTextField(JTextField field) { try { Integer.valueOf(field.getText()); field.setBackground(Color.WHITE); } catch (NumberFormatException e) { field.setBackground(Color.LIGHT_GRAY); return false; } return true; } }