@Override
        public void run() {
            long prevTime = 0;
            while (true) {
                //repaint at 60fps
                if (System.currentTimeMillis() - prevTime > 17) {  //1000 / 60 = 16.6, rounded up to 17 ms delay
                    panel.repaint();
                    prevTime = System.currentTimeMillis();
                }
            }
        }