Skip to content

Instantly share code, notes, and snippets.

@sasha2002
Forked from jintujacob/UsingSwingClass.java
Created November 2, 2018 23:44
Show Gist options
  • Save sasha2002/0c12cc209a0198df2d65672b6fb7d793 to your computer and use it in GitHub Desktop.
Save sasha2002/0c12cc209a0198df2d65672b6fb7d793 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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment