markwaldin
Technical User
I am trying to add a keylistener to my program but run into problems referencing non-static methods from main. Here is the jist of it:
class myprogram {
respondToKey instanceofKeyresponse = new respondToKey();
class respondToKey extends keyAdapter {
dosomething;
}
public void main(){
myprograminstance = new myprogram();
myprograminstance.addKeyListener(instanceofKeyresponse);
}
}
This causes an error for referencing a non-static variable from a static context (main) which I would expect. But how go I go about getting the keylistener activated?
Any help would be appreciated.
class myprogram {
respondToKey instanceofKeyresponse = new respondToKey();
class respondToKey extends keyAdapter {
dosomething;
}
public void main(){
myprograminstance = new myprogram();
myprograminstance.addKeyListener(instanceofKeyresponse);
}
}
This causes an error for referencing a non-static variable from a static context (main) which I would expect. But how go I go about getting the keylistener activated?
Any help would be appreciated.