just a simple Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jasoncai
    New Member
    • Feb 2008
    • 5

    just a simple Question

    System.out.prin t("data> ");
    command=scan.ne xtLine();
    if (command == "Enter")
    System.out.prin tln("yes");

    how can i vertify if command == "Enter"
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    I think using Scanner is not capable to handle 'Enter' key....

    But if you make a GUI....

    for example, you make a simple dialog with a textfield....

    You can use KeyEvent for this... It is a powerful built-in class with amazing methods that could capture all keyboard inputs (any combination),

    like char, text, the ascii, ctrl down? or not, alt pressed? or not... etc....
    Specially the 'Enter'...

    Correct me if im wrong....


    Sukatoa (Shadow Shaman)

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by jasoncai
      System.out.prin t("data> ");
      command=scan.ne xtLine();
      if (command == "Enter")
      System.out.prin tln("yes");

      how can i vertify if command == "Enter"
      Yes you can use Scanner. Read about how to use it here.
      P.S Do not use == for comparing Strings, use the equals method instead.

      Comment

      Working...