**ok so im trying to have my code loop if the user clicks no after entering their input ** `import java.awt.event.WindowAdapter; import javax.swing.JFrame; import javax.swing.JOptionPane;
public class Sizer extends WindowAdapter
{
public static void main (String[]args){
JFrame m = new JFrame();
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");
String input1= JOptionPane.showInputDialog("Height (suggested under 1080 and above 300)");
int Height= Integer.parseInt( input1);
after this input i have it set to confirm if this user entered it in correctly if they click yes it keeps going if they click no it exits i want it to have the user type it in again how would i do this
int a1 = JOptionPane.showConfirmDialog(m,"Are you sure that this is the correct Height"+ Height);
if (a1==JOptionPane.YES_OPTION){
if (a1==JOptionPane.NO_OPTION){
}
String input2= JOptionPane.showInputDialog("Width (suggested under 1920 and above 300)");
int Width = Integer.parseInt( input2);
JFrame frame = new JFrame();
Slop comp = new Slop();
frame.add(comp);
frame.setSize(Height,Width);
frame.setTitle("Slop of a Line");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
}
`
Aucun commentaire:
Enregistrer un commentaire