0
GUI program having lots of bugs
import javax.swing.JOptionPane; public class NumberDialog { public static void main(String[] args) { // Ask the user to enter a number String input = JOptionPane.showInputDialog(null, "Please enter a number:"); try { // Parse the number from the input string int number = Integer.parseInt(input); // Display the number in a message dialog JOptionPane.showMessageDialog(null, "You entered: " + number); } catch (NumberFormatException e) { // Handle invalid input by displaying an error message JOptionPane.showMessageDialog(null, "Invalid input. Please enter a valid integer."); } } }
2 Respostas
+ 2
Sololearn doesn't support GUI so you should try on any IDE.
0
Okay