I tried the solutions in this thread and the ones here , but just called setExtendedState(getExtendedState()|Frame.MAXIMIZED_BOTH); immediately after calling setVisible(true); obviously not working for my environment (Windows 10, JDK 1.8, my taskbar is on the right side of my screen). By doing this this way, there is still a tiny space left, right and bottom.
However, what worked for me was calling setExtendedState(... when the window is activated, like this:
public class SomeFrame extends JFrame { public SomeFrame() { // ... setVisible(true); setResizable(true); // if you are calling setSize() for fallback size, do that here addWindowListener ( new WindowAdapter() { private boolean shown = false; @Override public void windowActivated(WindowEvent we) { if(shown) return; shown = true; setExtendedState(getExtendedState()|JFrame.MAXIMIZED_BOTH); } } ); } }
TT. Apr 9 '19 at 12:02 2019-04-09 12:02
source share