hi i started java about 6 months ago and i have a struglling thing about the keylistener… in a gui i am suppose to make a object move like a image when i press the up , down , right and left key. can anyone give me an example or help me
Do you understand interfaces? If so, please post your code that implements KeyListener, and we’ll help you smooth it out. 
oh srry. well i can’t give you a example because its kind of useless… lol but i am look for a keyevent for when i press a key in the keyboard like the arrow key a image or icon would move in a gui.
i got some examples like:
case KeyEvent.VK_LEFT:
x -= speed;
x = Math.max (x, 0);
break;
case KeyEvent.VK_RIGHT:
x += speed;
x = Math.min (x, 300);
break;
case KeyEvent.VK_UP:
y -= speed;
y = Math.max (y, 0);
break;
case KeyEvent.VK_DOWN:
y += speed;
y = Math.min (y, 200);
break;
but i don’t know how to use this.
Ok. So do you know what an interface is? (This is VERY important. It’s the entire key to making listeners work.)
P.S. Mods: Can we move this to the Newless Clubies section? I don’t think that General Java is quite the right place for it. 
lol no i don’t
and yes i think you should i cound’t find where newbies were lol
[quote]lol no i don’t
[/quote]
FYI, you can find it in the Java Tutorial here:
http://java.sun.com/docs/books/tutorial/java/interpack/interfaces.html
The long and short of it is that Interfaces are a collection of methods that must be implemented by a class. Any class that implements those methods may act as if it was a class of the same type as the interface. KeyListener is an example of such an interface.
Here is an example of an interface:
public interface Thermometer
{
public int getTemperature();
}
That should compile to a .class file called Thermometer.class. Now, we might have a few different instances of a thermometer. e.g.:
public class CelsiusThermometer implements Thermometer
{
public int getTemperature()
{
return 10;
}
}
public class FahrenheitThermometer implements Thermometer
{
public int getTemperature()
{
return 50;
}
}
Note how both classes implement Thermometer. Also note that they won’t compile without the “getTemperature()” method. Now we can use them like this:
public class CheckTemp
{
public static void main(String[] args)
{
Thermometer[] therms = {new CelsiusThermometer(), new FahrenheitThermometer()};
for(int i=0; i<therms.length; i++)
{
System.out.println("Thermometer "+i+" says "+therms[i].getTemperature()+" degrees.");
}
}
}
See how those two different classes can be cast to the same class type? The same thing is true of KeyListener. Once you implement KeyListener, you then pass your class to the “addKeyListener()” method on the component you’re trying to listen to.
If you’re still having trouble, I suggest going through the Java Tutorial in detail:
http://java.sun.com/docs/books/tutorial/index.html
And if you ever want to become an expert in Java, you should also take the time to understand the JavaDocs:
http://java.sun.com/j2se/1.4.2/docs/api/index.html
Hope this helps! 
thx a lot