Question

I am trying to create a text based adventure in Java I need help in combining a Scanner with JPanel so that the user can type into the panel directly rather than choosing from a list of options. Is there any way of doing this or would a dialogue be needed and if so is there a way of doing so within the JPanel?

Was it helpful?

Solution

For doing so, you need to add some components to your panel, such as, JtextField or JTextArea.

Then you have to add a action listener to your text field/area.

You can find a lot of advices with a simple google search.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top