« Return to Thread: Closing a form from another one

Re: Closing a form from another one

by Jeffrey H. Coffield :: Rate this Message:

Reply to Author | View in Thread



AlexanderPD wrote:

> Hi, using the netbeans Gui builder i made 2 form, "a" and "b"
>
>
>
> If i need to close form "a" from "a" i simply need to use:
>
> this.setVisible(false);
>
>
>
> it works! :D
>
> but now i need to close "a" from "b" :|
>
> using a.setVisible(false); makes an "non-static method setVisible(boolean) cannot be referenced from a static context" :(
>
>
>
> How can i close "a" from "b"? :(
>
>
>
> thank you :)
>
>
> .
>
Somewhere you are creating form a and form b. I assume something like a
formA = new a(); and b formB = new b();. So you need to
get formA into formB so it can reference the real object, not just it's
class. If b is being created by a then you could modify b to have a
constructor method of b(a formA). Then in a you could have b formB = new
b(this). Then in b you can save off the formA and when needed do a
formA.setVisible(false);

Without seeing more of your code, this is only a guess.

Jeff Coffield
www.digitalsynergyinc.com

 « Return to Thread: Closing a form from another one