0

I tried to resize the window of my JFrame to automatically fit my screen upon running using the following code:

private void makeFrameFullSize(JFrame aFrame)
{
 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
 aFrame.setSize(screenSize.width, screenSize.height);
}

However, it did not work. how do I automatically expand the JFrame to fit my size of the screen in NetBeans

UmarZaii
  • 1,355
  • 1
  • 17
  • 26
J.Oginga
  • 124
  • 2
  • 9

1 Answers1

0

Try something like this:

private void makeFrameFullSize(JFrame aFrame)
{
   int state = aFrame.getExtendedState();
   aFrame.setExtendedState(stats | Frame.MAXIMIZED_BOTH);
}

See: https://docs.oracle.com/javase/8/docs/api/java/awt/Frame.html#setExtendedState-int-

Usagi Miyamoto
  • 6,196
  • 1
  • 19
  • 33