Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4025033

Win95/NT and Solaris: Carriage Return (keyDown) have different values.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 1.1
    • 1.1
    • client-libs
    • None
    • 1.1beta3
    • generic
    • windows_95
    • Not verified

      Win95/NT and Solaris: Carriage Return (keyDown) have different values.
      Workaround exists.

      Source code example:

      import java.awt.*;
      import java.io.*;


      public class Bug3
      extends Frame
      {

          MenuBar testMenuBar;
          Menu testMenu;
          MenuItem exit;

          public Bug3 (String Title)
          {
      super(Title);

      setLayout (new BorderLayout());

      testMenuBar = new MenuBar();
      setMenuBar(testMenuBar);
      testMenu = new Menu("TestMenu");
      testMenuBar.add(testMenu);
      exit = new MenuItem("Exit");
      testMenu.add(exit);
          }

          // keyDown
          public boolean keyDown(Event evt, int key)
          {

      //////////////////////////////////////////////////////////////////////
      // bugNo 3 : carriage return gives key value \\r in NT/95 and \\n in UNIX
      //////////////////////////////////////////////////////////////////////
      if(key == '\t'){
      System.out.println("Key down is \\t");
      }
      else if(key == '\r'){
      System.out.println("Key down is \\r");
      }
      else if(key == '\n'){
      System.out.println("Key down is \\n");
      }

      return false;
          }

          // handleEvent
          public boolean handleEvent(Event event)
          {

      switch(event.id){

      case Event.ACTION_EVENT:
      if(event.target instanceof MenuItem){
      if(event.target == exit){
      System.exit(0);
      }
      }
      break;
      default:
      break;
      }
      return super.handleEvent(event);
          }


          // main
          public static void main(String args[])
          {

      Bug3 test = new Bug3("Bug3");
      test.pack();
      test.resize(400,200);
      test.show();
          }

      }

            tballsunw Tom Ball (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: