@Override
    public void paintComponent(Graphics graphics) {
        if (tileSheet != null) {
            int x = 0;
            int y = 0;
            for (Tile tile : tileSheet.getTiles()) {
                graphics.setColor(Color.WHITE);
                graphics.fillRect(x, y, 8, 8);
                graphics.fillRect(x + 8, y + 8, 8, 8);
                graphics.setColor(Color.GRAY);
                graphics.fillRect(x + 8, y, 8, 8);
                graphics.fillRect(x, y + 8, 8, 8);
                graphics.drawImage(tile.getImage(), x, y, null);
                x += tileSheet.getTileWidth();
                if (x >= getWidth()) {
                    x = 0;
                    y += 16;
                }
            }
            x = 0;
            y = 0;
            for (Tile tile : tileSheet.getTiles()) {
                if (tile.isSelected()) {
                    graphics.setColor(Color.RED);
                    graphics.drawRect(x, y, tileSheet.getTileWidth() - 1, tileSheet.getTileHeight() - 1);
                }
                x += tileSheet.getTileWidth();
                if (x >= getWidth()) {
                    x = 0;
                    y += 16;
                }
            }
        }
    }