java - Calling SwingUtilities.invokeAndWait in a loop -


i trying save .png image of jframe. in jframe, have 2 plot3dpanel objects. because of synchronization fault, left-size frame invisible while saving .png.

enter image description here

therefore, use following code:

try {     swingutilities.invokeandwait(new runnable() {         public void run() {             new visualserializer(p[i], q[i], folder + "c" + i).run();         }     });      serialize(p[i], folder + "p" + i);     serialize(q[i], folder + "p" + i);  } catch(exception e) {     e.printstacktrace(); } 

but now, compile error

cannot refer non-final variable inside inner class defined in different method

however, need filenames different. also, need iterate through array of objects. can prevent error?

one way make final copies of variable needs passed anonymous inner class, instance if i problem:

final int index = i; swingutilities.invokeandwait(new runnable() {     public void run() {         new visualserializer(p[index], q[index], folder + "c" + index).run();     } }); 

another solution use class fields inside of anonymous inner class.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -