How to minimize Main frame when opening a new frame

0

I have a problem, I created a java application with a menu that calls several screens. When I opened some screen, I wanted my main application screen to be minimized. I tried with setvisible(false) but it did not work out as expected.

How can I do this?

    
asked by anonymous 13.06.2016 / 16:54

1 answer

2

Create a constructor on the secondary screens, getting a JFrame as a parameter, something like this:

public JanelaSecundaria(Frame frame)  {

    //...

    frame.setExtendedState(JFrame.ICONIFIED);

    //...
}

And when instantiating your sub windows within the main Frame, pass it as a reference:

JanelaSecundaria j2 = new JanelaSecundaria(this);
    
13.06.2016 / 16:55