Index: /applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java
===================================================================
--- /applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java	(revision 13558)
+++ /applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java	(revision 13559)
@@ -67,6 +67,14 @@
 				if ((way.nodes.size() == 5) &&
 						way.isClosed()) {
-					terraceBuilding(way);
-
+					// first ask the user how many buildings to terrace into
+					String answer = 
+						JOptionPane.showInputDialog(
+								tr("How many buildings are in the terrace?"));
+					
+					// if the answer was null then the user clicked "Cancel"
+					if (answer != null) {
+						int nb = Integer.parseInt(answer);
+						terraceBuilding(way, nb);
+					}
 				} else {
 					badSelect = true;
@@ -94,10 +102,7 @@
 	 * 
 	 * @param w The closed, quadrilateral way to terrace.
+	 * @param nb The number of buildings to terrace into.
 	 */
-	private void terraceBuilding(Way w) {
-		// first ask the user how many buildings to terrace into
-		int nb = Integer.parseInt(
-				JOptionPane.showInputDialog(
-						tr("How many buildings are in the terrace?")));
+	private void terraceBuilding(Way w, int nb) {
 
 		// now find which is the longest side connecting the first node
