java - MVP, JFrame, JDialog : GUI is freezing -
i have main frame (with jframe field) asi view, presenter (created in view's constructor) adds listeners buttons , stuff. this:
public static void main(final string[] args) { eventqueue.invokelater(new runnable() { @override public void run() { try { mywindow window = new mywindow(); window.frame.setvisible(true); } catch (exception e) { e.printstacktrace(); } } }); } mywindow invokes in it's constructor 1 method - intialize - creates gui fields. (literally last line of it's code) creates presenter.
presenter should show new jdialog on events in main view. has 1 method, that makes gui freeze. looks this:
protected double[] getparams(final class<?> indicatorclass) { parametrizabledialog dialog = dialogs.get(indicatorclass); // works list<double> params = new arraylist<double>(); dialog.setparams(params); dialog.setmodal(true); dialog.setlocationrelativeto(view.getframe()); dialog.setvisible(true); system.out.println(params); // works, params obtained jdialog user input return doubles.toarray(params); // guava } parametrizabledialog normal jdialog implements 1 method interface sets list<double> parameters this:
public class parametrizabledialog extends jdialog implements parametrizable { protected list<double> params; @override public void setparams(final list<double> params) { this.params = params; } } now, know mistake did make , why gui freeze? thanks!
if gui freezes, because blocking edt. read section swing tutorial on concurrency more information.
we can't tell doing because code isn't complete. example don't add components gui. knows doing in code left out.
for more post sscce demonstrates problem.
Comments
Post a Comment