Scanner sc = new Scanner(System.in);
This line is used for scanner to read an input from the console. How would you expect it to read from the
JTextField ?
To retrieve value from
JTextField, it should be something like
int a = t1.getText();
If you want to increase the width of the
JTextField, use
JTextField(5) instead, don't use
JTextField(" ").