public void addTwoPlusTwo() {
int num1, num2;
try{
String text1 = jTextField1.getText();
String text2 = jTextField2.getText();
num1 = Integer.parseInt(text1);
num2 = Integer.parseInt(text2);
JOptionPane.showMessageDialog(null, num1+num2);
JOptionPane.showMessageDialog(null, "Example JOptionPane!");
}catch(Exception e)
{
JOptionPane.showMessageDialog(null, "You need numbers");
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment