penDown handler for UITest.

Java for Small Spaces
Developing Java for small spaces
Chris Carpenter
Listing 1. penDown handler for UITest.


public void penDown(int x, int y) {

	if (exitButton.pressed(x, y)) {
		System.exit(0);
	}

	if (clearButton.pressed(x, y)) {
		textFieldOne.setText("");
		textFieldOne.paint();
		textFieldTwo.setText("");
		textFieldTwo.paint();
	}

	if (slider.contains(x, y)) {
		slider.handlePenDown(x, y);
	}

	if (textFieldOne.pressed(x, y) && (!textFieldOne.hasFocus())) {
		textFieldTwo.loseFocus();
		textFieldOne.setFocus();
	}

	if (textFieldTwo.pressed(x, y) && (!textFieldTwo.hasFocus())) {
		textFieldOne.loseFocus();
		textFieldTwo.setFocus();
	}

}

About the Author

Chris Carpenter is a software engineer and architect at RoleModel Software, Inc. in Holly Springs, NC. He can be contacted at [email protected].