JPanel overrides revalidate ()
For my program I have JPane
one that adds labels to the panel as the game progresses, however the only way I can show the panels is to use add(label)
and then retest and vice versa to remove the labels.
My problem is that when it gets to the point that I have more than 40 shortcuts on the screen, the revalidate has to handle too many things, as I can override work revalidate()
, ether, so that it only revalidates the specific component added. not every component on the screen. I know there is a loop somewhere inside the method revalidate()
that will loop through the loop of all components, but I just can't find it for life. I would like to be able to call revalidate(component-here)
or validate (component-here)
and update only that specific component.
I know there are other ways to write this program, but I'm only interested in how to override revalidate()
, so no "you could rewrite all your code in a way that should only take 6 hours>. <".
http://www.fileserve.com/file/jFdQ6nv/FINAL_PROJECT.zip link to my eclipse project if anyone who wants to help would like to see what abouyt actually says to them
source to share
I just tried this one. It only takes a second to add 1000 text areas, and updates are instant. Labels go even faster. You might want to look at something else slowing it down.
Also, you can take a look CellRendererPane
. He cancels invalidate()
to do nothing.
public void invalidate() {}
source to share