How do you hide a Swing Popup when you click somewhere else

前端 未结 6 2306
走了就别回头了
走了就别回头了 2021-01-04 06:26

I have a Popup that is shown when a user clicks on a button. I would like to hide the popup when any of the following events occur:

  1. The user clicks somewhere e
6条回答
  •  感动是毒
    2021-01-04 06:59

    You can add MouseListener to your background panel and hide the popup when somebody clicks on the panel.

    To react on application minimization, use WindowListener attached to a JFrame.

    Etc, etc. May seem tedious, but surely will work.

提交回复
热议问题