Must be pressed before pressing the key
I finally managed to get my GraphicsProgram in java to remove a specific GObject on pressing the spacebar.
This is the code:
public void keyPressed(KeyEvent key){
int space = key.getKeyCode();
if (space == KeyEvent.VK_SPACE){
remove(welcome);
}
}
The problem is that if I run my program, it doesn't recognize that I am entering the GraphicsWindow program that is being launched. (It's a bit tricky to explain) Basically, I first have to click inside the window before it recognizes the spacebar being pressed.
If this is not the first time I click on my window, it does not know that I am inside it, and does not recognize the entrance to the spacebar.
So, is there a way for java to open a window (I do this from CMD in windows) in the "front", if you are, immediately prepared to enter a space?
(If this is a Windows OS problem and not a Java problem, then I just need to find a workaround)
source to share
No one has answered this question yet
See similar questions:
or similar: