JTextField - Getting Keyboard Input - Java Extra 6

Поделиться
HTML-код
  • Опубликовано: 24 окт 2024

Комментарии • 10

  • @jonahbatut5382
    @jonahbatut5382 7 лет назад +2

    Awesome, as always!

  • @marxman2
    @marxman2 7 лет назад

    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?

    • @RyiSnow
      @RyiSnow  7 лет назад

      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.

  • @mukmusicdiary
    @mukmusicdiary 7 лет назад

    Awesome tutorial!! By any chance do you know how to make when enter is pressed? rather than the button?

    • @RyiSnow
      @RyiSnow  7 лет назад +2

      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 ;)

    • @mukmusicdiary
      @mukmusicdiary 7 лет назад

      Thank's heaps for your help :) Worked perfectly!!

  • @clickinf
    @clickinf 2 года назад

    is still java swing used? Is JAVA FX better?

  • @mukmusicdiary
    @mukmusicdiary 7 лет назад

    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.

    • @RyiSnow
      @RyiSnow  7 лет назад

      Hmm why don't you take player input as String and use it as a criteria for the switch?