Alex S. Diaz
Alex S. Diaz

Reputation: 2667

How can I know if my JFrame is currently minimized?

I have read this question and, in order to get the current "status" of my JFrame I have added a property like:

private static boolean isMinimized = false;

And then using WindowsListener I change this "property" within windowIconified(), windowDeiconified() methods, but I feel like I'm missing something.

Is there a property inside the JFrame class that let me know if my app is currently minimized or not? like... myFrame.isMinimized() or myFrame.isIconified()?

I feel like this is a really simple question, and I guess this already has an obvious answer, so if this is the case, feel free to mark it like duplicated.

Upvotes: 1

Views: 842

Answers (1)

John Bollinger
John Bollinger

Reputation: 180113

Is there a property inside the JFrame class that let me know if my app is currently minimized or not? like... myFrame.isMinimized() or myFrame.isIconified()?

Yes. You are looking for myFrame.getExtendedState() & Frame.ICONIFIED != 0.

Upvotes: 5

Related Questions