Adding a key listener to a component that can get the focus will work.
Adding a key listener to a component that is not configured to take the focus won't work until that component's method is...
Type: Posts; User: Norm
Adding a key listener to a component that can get the focus will work.
Adding a key listener to a component that is not configured to take the focus won't work until that component's method is...
Is the MyPanel object able to get the focus? See the doc at the link.
Did you see this from post#12
Can the MyPanel object get the focus? Not all components can. You may need to call a method that makes it possible for the MyPanel object to get the focus. It's...
If you want a reference to the MyPanel object you should use an assignment statement with the new operator. Then use that reference to call the methods and to pass the reference to the add() method....
Where is the MyPanel object created? Use the reference to the object that is created there to call that object's methods. Or do it in the constructor.
Can the MyPanel object get the focus? Not...
Get a reference to the object and use that to call the method.
Also you should read the tutorial about focus:
http://docs.oracle.com/javase/tutorial/uiswing/misc/focus.html
Does the View object get the focus? Add a focus listener to see if it gets and keeps the focus by printing out messages when it gets the focus and when it loses the focus.
What object has the key...
Post the code showing where you are trying.
Does the MyPanel object have the focus?