How to minimize Main Frame when opening a new frame

Asked

Viewed 435 times

0

I have a little problem, I created an application in java with a menu that calls several screens. When opening some screen, I wanted my application main screen to be minimized. I tried with setvisible(false) but did not result in the expected.

How can I do that?

1 answer

2


Create a builder on the secondary screens, getting a Jframe as a parameter, something like that:

public JanelaSecundaria(Frame frame)  {

    //...

    frame.setExtendedState(JFrame.ICONIFIED);

    //...
}

And when instantiating your secondary windows inside the main frame, pass it as a reference:

JanelaSecundaria j2 = new JanelaSecundaria(this);
  • Friend, I tried to put in the screen constructor that will open and also in the method that calls the screen and did not work

  • @Viniciusleonardo see the edition, if now works correctly.

  • Perfect, worked exactly, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.