Green
2015-03-25 23:11:23 UTC
But the problem is that the GUI is not appearing as expected.
Let consider the following code. This program is simple addition
program of two number. When run the program from Eclipse
the output interface is coming like this. photo given.This is
for other Java GUI program I am trying to Build.
What is the cause of it and how can fix it?
import javax.swing.JOptionPane;
public class Addition
{
public static void main( String[] args )
{
String firstNumber =
JOptionPane.showInputDialog( "Enter first integer" );
String secondNumber =
JOptionPane.showInputDialog( "Enter second integer" );
int number1 = Integer.parseInt( firstNumber );
int number2 = Integer.parseInt( secondNumber );
int sum = number1 + number2; // add numbers
JOptionPane.showMessageDialog( null, "The sum is " + sum,
"Sum Integers", JOptionPane.PLAIN_MESSAGE );
}
}