Skip to content

Instantly share code, notes, and snippets.

@jintujacob
Created June 14, 2011 11:52
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jintujacob/1024755 to your computer and use it in GitHub Desktop.
Save jintujacob/1024755 to your computer and use it in GitHub Desktop.
A java code to implement basic gui for input and output
import javax.swing.JOptionPane;
public class UsingSwingClass {
/**
* Implementinng the input dialog box and show message
*+box
* Something to check on the showMessage dialog box
* JOption.PLAIN_MESSAGE is the one without any icon
*/
public static void main(String[] args) {
String num1, num2;
int number1, number2, sum;
num1 = JOptionPane.showInputDialog("num1");
number1 = Integer.parseInt(num1);
num2 = JOptionPane.showInputDialog("num2");
number2 = Integer.parseInt(num2);
sum = number1 + number2;
JOptionPane.showMessageDialog(null, "the sum is : " + sum , "Results", JOptionPane.PLAIN_MESSAGE );
System.exit(0);
}
}
@realazaber
Copy link

Thanks for the code! I tried it out and it still works and it helped me learn more about Java.

@theahmadm3
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment