Search code examples
javajframedesktop-application

Keep Window in Back


This is most likely an obvious question, but I was wondering how I can keep a program behind all other windows (except the desktop)?

In a way, I am trying to achieve the opposite of keeping a window in the front.

Here's an example:

    Window 1
   Window 2
  Random Window
 My App
Desktop

However, I need it so that it will always stay against the desktop, so you cannot interact with it unless you're looking at the desktop itself.


Solution

  • public void toBack()here

    If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window. Places this Window at the bottom of the stacking order and shows it behind any other Windows in this VM. No action will take place is this Window is not visible. Some platforms do not allow Windows which are owned by other Windows to appear below their owners. Every attempt will be made to move this Window as low as possible in the stacking order; however, developers should not assume that this method will move this Window below all other windows in every situation.