Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

How do I hide a panel in graphics?

+16 votes
I have been working on this for  a while, but can't seem to figure out how to hide one of the Drawing Panels when two of them pop up. So far I've been using

public void setVisible(boolean visible) {

    frame.setVisible(visible);

}

which I think works, but right now it only works to shows the panel and doesn't hide the panel. Any suggestions on how to fix it?

-I altered it to fit with my variables for what I was calling the panel, so I know that isn't the problem.
asked Jan 13, 2016 in (Winter 15-16) by Taija Robinson (100 points)

1 Answer

+6 votes

This was my mistake:  I meant to include this information in the assignment sheet I handed out.  You are very close to the right track, but it's not that complicated -- you don't need to make your own setVisible() method, and there are no "frame" objects.

ANSWER:

There is a method called setVisible in the DrawingPanel class, so for example, if you have a DrawingPanel object named imagePanel , you can run the code:

imagePanel.setVisible(false);

(or imagePanel.setVisible(true); if you want it to appear again, but that's less relevant to this assignment...)

 

answered Jan 14, 2016 by Forrest Stonedahl (3,438 points)
...