Skip to main content

Thread: Help me as this applet java code is not responding to arrow movements...


help me applet java code not responding arrow movements...



import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class bhaja10 extends applet implements keylistener
{
int x=200,y=200;
string s;
public void init()
{
s="bradley richards";
addkeylistener(this);
}
public void keypressed(keyevent k)
{
if(k.getkeycode()==keyevent.vk_left)
x=x-10;

else if(k.getkeycode()==keyevent.vk_right)
x=x+10;

else if(k.getkeycode()==keyevent.vk_up)
y=y-10;

else if(k.getkeycode()==keyevent.vk_down)
y=y+10;

repaint();
}
public void paint(graphics g)
{
g.drawstring(s,x,y);
}

public void keytyped(keyevent k)
{}
public void keyreleased(keyevent k)
{}

}

looks ok... don't keyboard events unless have focus, have click on applet before using keyboard.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Help me as this applet java code is not responding to arrow movements...


Ubuntu

Comments

Popular posts from this blog

Thread: Can not create raid array: mdadm: no raid-devices specified.

Thread: HOW TO: Package and theme GTK+ / Gtkmm apps in Linux for Windows

Thread: Twinview issues