protected void createAndShowGUI() { GamePanel gamePanel = new GamePanel(); gamePanel.setBackground(Color.WHITE); gamePanel.setPreferredSize(new Dimension(320, 240)); getContentPane().add(gamePanel); setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Hello World!"); pack(); frameRate.initialize(); setVisible(true); }
protected void onPaint(Graphics g) { frameRate.calculate(); g.setColor(Color.BLACK); g.drawString(frameRate.getFrameRate(), 30, 30); repaint(); }
/** * Creates an {@link AnimationTimer} with an specified frame rate * * @param fps {@link FrameRate} we want to use for this {@link AnimationTimer} */ public AnimationTimer(FrameRate fps) { fTimer = new Timer(fps.delay(), new TimerActionListener()); }