Your code throws an IllegalArgumentException because the initial content string ("Enter A") does not respect the constraint (NUMERIC). You should use:
a = new TextField("Enter A", "0", 40, TextField.NUMERIC);
b = new TextField("Enter B", "0", 4, TextField.NUMERIC);