Skip to main content



      Home
Home » Newcomers » Newcomers » Eclipse: Java [ Not Detecting Key Pressed ]
Eclipse: Java [ Not Detecting Key Pressed ] [message #1702074] Sat, 18 July 2015 13:51 Go to next message
Eclipse UserFriend
My eciipse wont let me detect keyPressed, how do I fix this?


public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
if (e.getKeyCode() == KeyEvent.VK_W)
{
rect.setLocation(rect.x+2, rect.y);
System.out.println("Click");
}
else if (e.getKeyCode() == KeyEvent.VK_LEFT)
{

rect.setLocation(rect.x-2, rect.y);
}
else if (e.getKeyCode() == KeyEvent.VK_UP)
{

rect.setLocation(rect.x, rect.y+2);
}
else if (e.getKeyCode() == KeyEvent.VK_DOWN)
{
rect.setLocation(rect.x, rect.y-2); //
}

repaint();
Re: Eclipse: Java [ Not Detecting Key Pressed ] [message #1702160 is a reply to message #1702074] Mon, 20 July 2015 08:10 Go to previous message
Eclipse UserFriend
This looks more like a general Java AWT question than one specific to Eclipse. You'll reach a wider and more apt audience on places like http://javaranch.com and http://stackoverflow.com .
Previous Topic:Error while opening the eclipse
Next Topic:Eclipse to TFS
Goto Forum:
  


Current Time: Fri May 23 16:54:42 EDT 2025

Powered by FUDForum. Page generated in 0.08066 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top