Duplicate :
|
Problem: - setExtendedState ignores the screen insets by default(i.e. the windows task bar) -> Workaround would be to use setMaximizedBounds - setMaximizedBounds works well on single screen or dual screen, if both screens have the same size - if the secondary screen is wider than the primary, setMaximizedBounds and setExtendedState( Frame.MAXIMIZED_BOTH ) on the secondary screen result in a frame which is wider than the screen size allows Steps to reproduce the error: - two screens, the wider screen has the same height like the first one and is to the right of the first one - start the program, move the frame to the secondary screen, click on the button Analysis: - if we set the maximized bounds on the secondary screen to the width of of the primary screen, the frame gets the correct size( even though the size we've set was to small!) - any wider size ( the real width of the secondary for instance) result in a too wide maximized frame - any smaller size than the width of the primary screen will maximize to exactly this width in pixels on the secondary.