package main; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import javax.swing.JPanel; public class MainScreen extends JPanel { private Image bufferImage; private Graphics2D buffer; public MainScreen() { bufferImage = createImage(MainClass.SCREEN_WIDTH, MainClass.SCREEN_HEIGHT); buffer = (Graphics2D)bufferImage.getGraphics(); } @Override public void paintComponent(Graphics g) { buffer.setColor(new Color(0x000000)); buffer.fillRect(0, 0, MainClass.SCREEN_WIDTH, MainClass.SCREEN_HEIGHT); buffer.setColor(new Color(0xffffff)); buffer.drawString("W: " + MainClass.SCREEN_WIDTH, 20, 20); g.drawImage(bufferImage, 0, 0, this); } }