Results 1 to 3 of 3
  1. #1
    Camzie is offline Member
    Join Date
    Nov 2009
    Location
    Pretoria
    Posts
    12
    Rep Power
    0

    Exclamation Struggling with OnKeyPressed Event in java

    Hi there

    Iam struggling with the OnKeyPressed event in java.
    This code doesn't work and it doesn't display anything
    I want to know why

    public void OnKeyPressed(Object source, KeyEvent e)
    {
    System.err.println("com.mca.portal.PagePassword.On KeyPressed()");

    switch (e.getKeyCode())
    {
    case HKeyEvent.VK_UP:
    this.requestFocus();
    break;

    case HKeyEvent.VK_0: SetInput('0'); return;
    case HKeyEvent.VK_1: SetInput('1'); return;
    case HKeyEvent.VK_2: SetInput('2'); return;
    case HKeyEvent.VK_3: SetInput('3'); return;
    case HKeyEvent.VK_4: SetInput('4'); return;
    case HKeyEvent.VK_5: SetInput('5'); return;
    case HKeyEvent.VK_6: SetInput('6'); return;
    case HKeyEvent.VK_7: SetInput('7'); return;
    case HKeyEvent.VK_8: SetInput('8'); return;
    case HKeyEvent.VK_9: SetInput('9'); return;

    case HKeyEvent.VK_ACCEPT:
    case HKeyEvent.VK_ENTER:
    //if (TestInput()) Application.Run(PortalPage.CreateInstance(_pageNex t));
    return;

    case HKeyEvent.VK_CANCEL:
    case HKeyEvent.VK_ESCAPE:
    case HKeyEvent.VK_F9:
    Application.Run(PortalPage.CreateInstance(_pageCan cel));
    //Application.Run(new PageMainMenu());
    return;
    }

    if (_count == _passcode.length())
    {
    if (TestInput())
    {
    //Application.Run(PortalPage.CreateInstance(_pageNex t));
    }
    }

    super.OnKeyPressed(source, e);
    }

    Thanx
    Camzie

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

  3. #3
    Camzie is offline Member
    Join Date
    Nov 2009
    Location
    Pretoria
    Posts
    12
    Rep Power
    0

    Default

    Hi
    I got it from one of my Java books, a Java 6.16 version

Similar Threads

  1. Struggling with java .ini files
    By Camzie in forum NetBeans
    Replies: 6
    Last Post: 11-24-2009, 04:13 PM
  2. Replies: 3
    Last Post: 03-26-2009, 11:31 PM
  3. struggling with creating a GUI
    By tuwannu in forum Advanced Java
    Replies: 2
    Last Post: 12-01-2008, 03:53 PM
  4. Generate an event to another java application
    By i_berbeu in forum Advanced Java
    Replies: 18
    Last Post: 05-12-2008, 02:57 PM
  5. difference btwn java.awt.* and java.awt.event.*
    By ahdus in forum New To Java
    Replies: 5
    Last Post: 11-17-2007, 07:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •