문제

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