1

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.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Alex S. Diaz
  • 2,637
  • 2
  • 23
  • 35
  • *"How can I know if my JFrame is currently minimized?"* Why does it matter? See [What is the XY problem?](http://meta.stackexchange.com/q/66377) – Andrew Thompson Oct 02 '15 at 19:30
  • @AndrewThompson I need this because I add a close button to a trayicon and I would like to unminimize(?) the app if this is minimized before let user decide if he/she really want to close the app – Alex S. Diaz Oct 02 '15 at 19:44
  • 1
    *"..I would like to unminimize(?) the app if this is minimized"* Now it's sounding a bit like (a form of) premature optimization. Just set the state to **not minimized** (without any check) using `Frame.setExtendedState(NORMAL)`. – Andrew Thompson Oct 02 '15 at 20:36

1 Answers1

5

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.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157