This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Once again I post the topic. This time with shortened code.
Whenever I press a button (see my code below) the execution time of my app increases (if run my app, please press the button at least 5 times). Has anyone encountered such a problem when using SpringLayout?
If I change layout the app works fine. I would grateful for any suggestions.
If you press the button 5 times, there will be 90 labels. Why does it surprise you that laying out a container takes longer the more components are in it? Especially given that SpringLayout works by defining relationships between components, even quadratic performance in the number of components wouldn't be a big surprise.
Another layout manager like, say, GridLayout would handle this very differently: it forces all the components to be the same size, which it computes without asking any of them its preferred dimensions -- so it's obviously going to be much faster!