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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top