This isn't javascript. Moving from Javascript to Java forum.
These are somewhat incompatible. Scanner is designed to tokenize and parse input; when you specify that it comes from System.in, that allows easy interaction with the keyboard.
An applet is a gui component, in this case a swing component. In order to create input you typically use input fields such as JTextField, or prompts using JOptionDialog classes.
If you use a JTextField, you have to add an event listener to it. FocusListener tends to be a good one when the field looses focus. This then is called and invokes the code specified by the event handler and does whatever it needs to do with the input. In the case of a number, a try/catch is used to cast an integer using the Integer.parseInt() method since all input from a text area .value() is a string. Same check needs to go on a JOptionDialog (or another JDialog type), but you don't need an event listener since a thread is used on the dialog and halts the processing of the program until it receives a response, similar to the nextLine() method of the scanner.
Needless to say, you cannot just go from a cli application to a gui. You need to learn the processes first, then write the gui. Oracle's documentation tutorials are pretty good:
http://docs.oracle.com/javase/tutori...ing/index.html
Also, in the future please wrap your code in [php][/php] or [code][/code] tags.