Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Eclipse: Java [ Not Detecting Key Pressed ]
Eclipse: Java [ Not Detecting Key Pressed ] [message #1702074] Sat, 18 July 2015 17:51 Go to next message
Nicolas Nguyen is currently offline Nicolas NguyenFriend
Messages: 2
Registered: July 2015
Junior Member
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 12:10 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4490
Registered: July 2009
Senior Member

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 .

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Error while opening the eclipse
Next Topic:Eclipse to TFS
Goto Forum:
  


Current Time: Mon Sep 23 03:45:49 GMT 2024

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

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

Back to the top