When you DECLARE a variable inside a method, that variable goes out of scope (can not reliably be accessed anymore) when you leave that method.So to do what you are trying to do, you want to DECLARE the variables inside the game class (making it a field of the game class and available everywhere within the game class, including inside the game class's paint method).