Hi !
I just figured that out while reading the API. But anyway thanks.
This is the code for anyone that has the same problem :
private class GUIKeyListener implements KeyListener {
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
if( e.isAltDown() ){
if( e.getKeyCode() == KeyEvent.VK_T ){
// action you want to perform
}
}
}
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
}
I have been having a problem with my code. I think its all ok, but it doesnt always work. If I run the program enough it eventually works that one time.
Here's some of the code:
public void keyTyped(KeyEvent e)
{
int key=e.getKeyCode();
char keychar=e.getKeyChar();
System.out.println("Key Code:" + key);
System.out.println("Key char:" + keychar);
//String keystr=KeyEvent.getKeyText(0);
//System.out.println("keystr is " + keystr);
//System.out.println(key);
if(ready)
{
if(keychar=='a')
{
System.out.println("LEFT");
if(xcoord>0)
{
xcoord--;
ready=Character.moveAnimation(1);
}
}
else if(keychar=='d')
{
System.out.println("RIGHT");
if(xcoord<15)
{
xcoord++;
ready=Character.moveAnimation(2);
}
}
else if(keychar=='w')
{
System.out.println("UP");
if(ycoord>1)
{
ycoord--;
ready=Character.moveAnimation(3);
}
}
else if(keychar=='s')
{
System.out.println("DOWN");
if(ycoord<8)
{
ycoord++;
ready=Character.moveAnimation(4);
}
}
System.out.println(ready);
}//End if ready
}
I want to use the arrow keys, but they are never read even when the rest of the keyboard works.
If you need more code to find the program please ask me!
I've been trying to find the answer to the problem for a while.
Hi all
can anybody pls give an explanation to this
If suppose i have pressed a key( For eg: Enter) then how the application knows that the key pressed is Enter key.
From my understanding Basically the eventq will contain the type of events, its corresponding keycodes & keychar. it is fiiling one strucure from the native implementation and sending those structure to java file.
I want to know the functional flow of event handling from the moment it fills the eventq to the executing section.
If a component contains "OK" and "CANCEL" button. with "OK" having the focus. and if i press "ENTER" how this is executing
currently i am using the pbp1.0 code with microwindows.
Can Anyone can give inputs on this. Thanks in advance