Nick H.
Nick H.

Reputation: 1

java - panel.getVisible?

it may be a stupid question, but I didn't find anything on google etc... So I have a panel, and want to know, if it is visible

if (pnlUnten.getVisible == false)

this one doesn't seem to work.

if (pnlUnten.isVisible == false)

if (pnlUnten.isVisible)

those both neither

I think there is a very easy solution for my problem, but I can't figure it out..

Upvotes: 0

Views: 9191

Answers (3)

smalling
smalling

Reputation: 11

All you need to do is this:

//this code checks if its visible

if (pnlUntel.isVisible())
    //do something

//this code below checks if its not visible

if (!pnlUntel.isVisible())
    //do something

[Example]

Upvotes: 1

FThompson
FThompson

Reputation: 28687

JPanel#getVisible() isn't a method, but JPanel#isVisible() is, as inherited from Component.

Upvotes: 1

dakotapearl
dakotapearl

Reputation: 373

It looks like isVisible is only an indication of whether the panel is visible. If it's true, then it's visible if it's parent is visible. So if you want to use this property, it seems like you'd need to combine it with checking the parent. I had a quick go, but nothing thorough.

My code: if (panel.isVisible() && panel.getParent().isVisible())

Upvotes: 5

Related Questions