如果用戶在輸入輸入后單擊“否”,我將嘗試讓我的代碼循環。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);在此輸入之后,我必須確認該用戶是否正確輸入了它,如果他們單擊“是”,它會繼續運行,如果他們單擊“否”,它會退出我希望它讓用戶再次輸入它,我該怎么做? 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); } }}
添加回答
舉報
0/150
提交
取消