here is my code, i basically just did a tester for the most common listeners, which i might later use in future projects, the main problem is in the keylistener at the bottom, i
Visible components can have the keyboard focus, and recieve keyboard and other input events, but invisible components cannot have the focus, nor recieve input events. When you make the frame invisible, it stops recieving input events, as does all it's children, including the test
component you are adding a KeyListener
to.
To make this work, you will have to have a visible component, and forward keyboard events from that to your invisible frame. Or better, call invisibelFrame.setVisible(true)
from your already visible component.
Alternatively, you may be able to find some other way to trigger showing the frame. For example, a system tray component, with a context menu is a common pattern for hiding and showing application frames (and for some users, causing much chagrin in the process!)
See