Whenever I need to grab input from the keyboard, I use the following KeyAdapter inner class technique.
controls = new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
//do something with input
}
};
It wasn't recently that I learned how to do this, but I am beginning to become uncomfortable, as I like to understand what is happening in my code. What exactly is Java doing here? The best I can come up with is it is a form of inner class, but why can't I write a constructor?
No comments:
Post a Comment