JFrame starting up slow

Hello there,
I have a JFrame set up as a display for my Java2D game. It all works perfectly except for one thing: If I add the following code to my render loop the frame doesn’t render for about a second.

	private void drawFPS(Graphics2D graphics, int fps) {
		if (hideFPS)
			return;
		// graphics.setFont(font);
		graphics.setColor(Color.WHITE);
		graphics.drawString(fps + "", 5, 15);
	}

So without using this method in my rendering loop the window starts up and the rendering start immediately. But using this method in the loop makes the frame show it’s standard background color (this litle dirty white) for about a second before the rendering results of the game loop get displayed.
What can I do here? I have had this problem in other occasions but until now, hadn’t figured out what exactly the problem is.

is hideFPS true or false?

Where is this in the game loop?

Are you using text anywhere else? Is that setFont() call definitely commented out when it’s still slow? Setting up text rendering and initialising a font can take a little bit of time.

Just comment out bits of that function until you identify which line is causing the problem.

hideFPS is false, what causes the problem. If I set it to true the frame starts up just normal.
And this is in my rendering loop, after the screen got cleared and after everything else (enemies,player,etc.) has been drawn.

It makes no difference, if setFonr() is commented out. Also, I’m not using text anywhere else.

This is (probably) why then. As I said, text rendering can take a little time to set up. You could try rendering some text somewhere prior to showing your JFrame and see if that masks the issue.

This is (probably) why then. As I said, text rendering can take a little time to set up. You could try rendering some text somewhere prior to showing your JFrame and see if that masks the issue.
[/quote]
I will try that and report back. I also noticed, that this problem was more apparent on my old MacMini 2012 than on a comparable performing Windows machine.