@Test public void testShouldYieldFocusValidInput() throws Exception { int min = 0; int max = 100; IntegerInputVerifier verifier = new IntegerInputVerifier(min, max, background, warningBackground); JTextField input = new JTextField(Integer.toString(min+5)); input.setBackground(warningBackground); assertTrue(verifier.shouldYieldFocus(input)); assertEquals("background was not reset", background, input.getBackground()); }
public boolean shouldYieldFocus(JComponent input) { boolean isValidInput = verify(input); if (isValidInput) { input.setBackground(background); } else { input.setBackground(warningBackground); } return isValidInput; }
IntegerInputVerifier extends InputVerifier { public boolean shouldYieldFocus(JComponent input) { boolean isValidInput = verify(input); if (isValidInput) { input.setBackground(background); } else { input.setBackground(warningBackground); } return isValidInput; } }
IntegerInputVerifier extends InputVerifier { public boolean shouldYieldFocus(JComponent input) { boolean isValidInput = verify(input); if (isValidInput) { input.setBackground(background); } else { input.setBackground(warningBackground); } return isValidInput; } IntegerInputVerifier(int min, int max, Color background, Color warningBackground); }
IntegerInputVerifier extends InputVerifier { public boolean shouldYieldFocus(JComponent input) { boolean isValidInput = verify(input); if (isValidInput) { input.setBackground(background); } else { input.setBackground(warningBackground); } return isValidInput; } IntegerInputVerifier(int min, int max, Color background, Color warningBackground); int getMin(); int getMax(); boolean shouldYieldFocus(JComponent input); boolean verify(JComponent input); }
IntegerInputVerifier extends InputVerifier { public boolean shouldYieldFocus(JComponent input) { boolean isValidInput = verify(input); if (isValidInput) { input.setBackground(background); } else { input.setBackground(warningBackground); } return isValidInput; } IntegerInputVerifier(int min, int max, Color background, Color warningBackground); int getMin(); int getMax(); boolean shouldYieldFocus(JComponent input); boolean verify(JComponent input);  }