private int getNumElements(final DataType dt, final int maxNoConflictElements,
			final int maxElements) {
		NumberInputDialog numberInputDialog = new NumberInputDialog("Create " + dt.getName() + "[]",
			"Enter number of array elements (1 - " + maxElements + ") :", maxNoConflictElements, 1,
			maxElements, false);
		if (maxNoConflictElements < maxElements) {
			numberInputDialog.setDefaultMessage(
				"Entering more than " + maxNoConflictElements + " will overwrite existing data");
		}
		if (!numberInputDialog.show()) {
			return Integer.MIN_VALUE; // cancelled
		}
		int value = numberInputDialog.getValue();
		if (value > maxNoConflictElements) {
			int result = OptionDialog.showYesNoDialog(null, "Overwrite Existing Data?",
				"Existing data will be overridden if you create this array.\n" +
					"Are you sure you want to continue?");
			if (result != OptionDialog.YES_OPTION) {
				return Integer.MIN_VALUE;  	// Cancel create array
			}
		}
		return value;
	}
Get the number of elements to create from the user.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/CreateArrayAction.java