I will try to provide as much detail as i can here. Please note I haven't posted to this forum before, so if this is a duplicate question, my apologies.
I have a mid-2010 MacBook Pro and run OSx Mavericks. I recently (last week) installed the standard edition of Windows 8.1 using bootcamp. The install went well, and everything is working ok; however....
I am a student of Java, and recently wrote a swing component for the game Sokoban. It runs very well on my Mac, and in Windows 7.....but it is not working on my Mac when in Windows 8.1. When I invoke the main method from either BlueJ or Eclipse, the program runs, but my keys are not responding. I know my keyboard works, as I have been able to use other programs wirhout issue. That said, I have narrowed my focus to this being a Java compatibility issue with Windows 8.1....am I correct? Here is my Key Listener from Sokoban. Keys are enumerated in a separate enum. I use the up, down, left, right, r, and n keys only.
/*
* This is the key listener for the class Sokoban.
*/
public class MyKeyListener implements KeyListener //Inner class that contains the key listener.
{
public void keyPressed(KeyEvent event)
{
if(isReady) { //Prevents actions from occuring and graphics being drawn before the level contents are loaded into gamePlay
int decimalCode = event.getKeyCode(); // get key code of the key pressed
//Find the current position of the PLAYER
for(int i = 0; i < curLevHt; i++) {
for(int j = 0; j < curLevWd; j++) {
if (gamePlay[i][j] == Contents.PLAYER || gamePlay[i][j] == Contents.PLAYERONGOAL) {
x = i; //assign the array coordinates to x and y
y = j;
}
}
}
//For the given arrow key press, assign the appropriate offsets to dx, ddx, dy, and ddy; then call method gameMove().
if(decimalCode == Keys.UPARROW.value && !gameComplete) {dx = x - 1; dy = y; ddx = dx -1; ddy = dy; gameMove();}//Move up offset
if(decimalCode == Keys.DOWNARROW.value && !gameComplete) {dx = x + 1; dy = y; ddx = dx + 1; ddy = dy; gameMove();}//Move down offset
if(decimalCode == Keys.LEFTARROW.value && !gameComplete) {dx = x; dy = y - 1; ddx = dx; ddy = dy -1; gameMove();}//Move left offset
if(decimalCode == Keys.RIGHTARROW.value && !gameComplete) {dx = x; dy = y + 1; ddx = dx; ddy = dy + 1; gameMove();}//Move right offset
//Increment to the next level of play when N key is pressed OR if a level is completed by calling method nextLevel().
if((goal || decimalCode == Keys.N.value) && currentLevel < numberOfLevels - 1) {nextLevel();}
//Reset the current level of play when R key is pressed by calling the method levelReset();
if(decimalCode == Keys.R.value && !gameComplete) {levelReset();}
//If last level of game is successfully completed turn gameComplete true, and turn on a "splash screen"
if(goal && currentLevel == numberOfLevels - 1) { //Game over.
gameComplete = true;
levelDesc.setText("GAME OVER, Press N to Restart");
timer.stop();//Stop the timer at the completion of the last level in the game.
repaint();
}
if(goal && decimalCode == Keys.N.value && currentLevel == numberOfLevels -1) {restartGame();}
}
}
public void keyReleased(KeyEvent event){
}
public void keyTyped(KeyEvent event){
}
}