views:

33

answers:

2

I want to make an if statement, BUT

I need to return the value of setVisible so I can make a statment like:

if(visible = false) { haha theres no code in here <_< }

I have no idea to return the value of setVisible.

EDIT: All of my JFrames are seperate programs called by the Main program, I want all of the frames to run individually and not together, chromatically one after the other at an actionPerformed event. But in the main program I need to determine whether a frame is set to visible, How would I go about doing this?

EDIT2: That or if there is some other way I could make an external JFrame run, when it closes it would assign something a value which would trigger the next external JFrame to run, but I cant seem to grasp what would trigger it.

A: 

if you see the prototype of the method setVisible, you will it doesn't return a value because it is a void method. If you want to obtain the visibility of a frame, you should instead isVisible.

Dimitri
A: 

Edit
It looks to me like you may want to be using a WindowListener. You can implement the WindowClosing method to have it display the next JFrame.

JFrame has the method isVisible(). You can use that to determine if the frame is visible or not.

if (!yourFrame.isVisible()) {
   // No code here...
}
jjnguy
Well, im calling the JFrame from another program and I need the main program to determine if the frame isnt visible, then if it isnt, the next frame will run. All my JFrames are programs of their own and all run from the main Program, but I need them all to run chromatically with only 1 being open at a time.
Nick Gibson
@Nick, what does 'calling the JFrame mean'?
jjnguy
I set the main program to Run the JFrame externally from another .java file that contains the JFrame and the contents. Nothing else. My main program is simply a container that holds the method to sequentially execute the JFrames one by one.
Nick Gibson
@Nick, ok, check out the edit to my answer
jjnguy
Ooh! wait, when the user presses a button that causes the JFrame to close...it would trigger a WindowClosing?
Nick Gibson
@Nick, if you cause the window to close in any way, the window closing event will trigger.
jjnguy
I Thank you alot. You have helped so much :P I've been researching on how to handle this for 2 days :)
Nick Gibson