0

How is it possible to add a "Scanner" for a text entry box in Java?

I would like such a box, in which you can enter your own name, for example, to be greeted - this time for Java :'D

11/24/2019 9:16:36 PM

2Beers

2 Answers

New Answer

+1

The wording of your question is a little weird, so my apologies if I answer wrong. If you're asking how to import scanner you type this outside of the class import java.util.Scanner; And to create the scanner object you type this in the main method (or whatever method you're using it in): Scanner input = new Scanner(System.in);

+1

You can use a TextField or a TextArea class to achieve what you want. TextField can only hold a single line but TextArea can hold multiple lines. Also you have to import applet and awt api. You can then create an instance of the above classes and use setText() and getText().