Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top