Results 1 to 3 of 3
- 11-25-2009, 11:59 AM #1
Member
- Join Date
- Nov 2009
- Location
- Pretoria
- Posts
- 12
- Rep Power
- 0
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
- 11-25-2009, 12:51 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Where did you get that OnKeyPressed method from?
How to Write a Key Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
- 12-01-2009, 07:58 AM #3
Member
- Join Date
- Nov 2009
- Location
- Pretoria
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
Struggling with java .ini files
By Camzie in forum NetBeansReplies: 6Last Post: 11-24-2009, 03:13 PM -
addActionListener(java.awt.event.ActionListener) in java.awt.Button cannot be applied
By mathias in forum Java AppletsReplies: 3Last Post: 03-26-2009, 10:31 PM -
struggling with creating a GUI
By tuwannu in forum Advanced JavaReplies: 2Last Post: 12-01-2008, 02:53 PM -
Generate an event to another java application
By i_berbeu in forum Advanced JavaReplies: 18Last Post: 05-12-2008, 01:57 PM -
difference btwn java.awt.* and java.awt.event.*
By ahdus in forum New To JavaReplies: 5Last Post: 11-17-2007, 06:07 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks