Setting a JFrame without overlapping with taskbar

前端 未结 2 1824

I need to have a undecorated JFrame(setUndecorated(true)) which need to be shown fullscreen, without overlapping with the taskbar.

I have t

2条回答
  •  花落未央
    2021-01-20 05:54

    Able to able to fix the above issue with the below code,

    Rectangle usableBounds = SunGraphicsEnvironment.getUsableBounds(config.getDevice());
    setMaximizedBounds(usableBounds);
    setExtendedState(MAXIMIZED_BOTH);
    

    So by getUsableBounds I am able to get the bounds leaving the taskbar. And hence I am using setExtendedState(MAXIMIZED_BOTH) the window is getting updated automatically when I re-size/re-position the taskbar. :-)

提交回复
热议问题