Thanks for this! But how do you advance to the next screen after the name is inputted? For example, after you display "hello x, let's start the game!", how do you actually make Java go to the game screen?
Please check my tutorial How to make a text adventure game in GUI ruclips.net/p/PL_QPQmz5C6WUMB0xEMZosWbyQo_Kil0Fb I've already explained it in this series.
Actually it's quite easy to do it. Just add this line after initializing JTextField: jtf.addActionListenr(iHandler) Then jtf (JTextField) is also linked with InputHandler so if you press enter after typing some texs, it will call InputHandler and the inputted text is displayed ;)
Hey, How would you set the switch statement to listen for the player input. I have an action listener but I don't know how to set it up for the switch statement. This is for the player choice.
Awesome, as always!
Thanks!
Thanks for this! But how do you advance to the next screen after the name is inputted? For example, after you display "hello x, let's start the game!", how do you actually make Java go to the game screen?
Please check my tutorial How to make a text adventure game in GUI ruclips.net/p/PL_QPQmz5C6WUMB0xEMZosWbyQo_Kil0Fb I've already explained it in this series.
Awesome tutorial!! By any chance do you know how to make when enter is pressed? rather than the button?
Actually it's quite easy to do it. Just add this line after initializing JTextField:
jtf.addActionListenr(iHandler)
Then jtf (JTextField) is also linked with InputHandler so if you press enter after typing some texs, it will call InputHandler and the inputted text is displayed ;)
Thank's heaps for your help :) Worked perfectly!!
is still java swing used? Is JAVA FX better?
Hey,
How would you set the switch statement to listen for the player input. I have an action listener but I don't know how to set it up for the switch statement. This is for the player choice.
Hmm why don't you take player input as String and use it as a criteria for the switch?