Используйте цикл do ... while и очистите высоту, если пользователь нажимает «нет»
public class Sizer extends WindowAdapter
{
public static void main (String[]args){
JFrame m = new JFrame();
int height = 0;
JOptionPane.showMessageDialog(m,"Ok To set the window size you are going to type in the number for each value REMEMBER THE SIZE IS IN PIXELS");
do {
String input1= JOptionPane.showInputDialog("Height (suggested under 1080 and above 300)");
height= Integer.parseInt(input1);
int a1 = JOptionPane.showConfirmDialog(m,"Are you sure that this is the correct Height "+ height);
if (a1==JOptionPane.NO_OPTION){
height = 0;
}
} while (height==0)
}
}
Это предполагает, что высота должна быть> 0. Если высота может быть 0, используйте -1 каквместо этого начальные и сбрасываемые значения.
РЕДАКТИРОВАТЬ:
@ Ответ Николаса К показывает, что на самом деле вам не нужен оператор if, вместо этого просто завершите цикл while следующим образом:
a1 = JOptionPane.showConfirmDialog(m,"Are you sure that this is the correct Height "+ height);
} while (a1==JOptionPane.NO_OPTION)
Для этого вам нужно инициализировать a1 в начале метода.