Wednesday, 15 July 2015

java - What is causing slow performance in my JTabbedPane-based Swing application? -



java - What is causing slow performance in my JTabbedPane-based Swing application? -

i have swing application creating rpg characters. has nested jtabbedpane architecture, there herotabspanel has heropanels , each of has more tabs stats, items etc.

so gui comprised of upper tabbed pane heroes, lower tabbed pane current hero tab , editviewpanel displays editingview corresponding each tab when tab selected.

performance has been bad start, when added upper level hero-tabs (to have multiple heroes in editing simultaneously), switching between tabs became slower. takes a few minutes displayed in new jframe after code has finished adding components. layout?

i using miglayout absolute positioning. actually, before added upper tabs, there had been “unstable cyclic dependency in absolute-linked values!” issues, there aren’t somehow.

in statechanged() have amounts this:

editviewpanel.activateview(currenttab.getlinkedview());

and in activateview():

removeall(); currentview = heroview; add(currentview, "pos 0 0"); currentview.refresh(); revalidate();

but said, code execution finished in reasonable time, i've done profiling, after done, there delay of considerable length, few minutes in case of first time adding new jframe.

another issue when need update panel within lower tabbedpane, statspanel made of string-int elements added each parameter in few columns, yet big delay. depends on miglayout , reason (bad design, know) has absolute positioning well. have changed no components removed/added after initialization, settext() used , still there big delay after code finished executing.

i’m planning utilize swingworkers understand problem improve before start solving it. suspect it's simple, bit incredulous how big delays it's causing are. i'd appreciate hints/examples swingworkers.

i can add together more code if have general thought issue might hide.

any suggestions welcome, thanks!

i never encountered swing ui slow due number of jcomponents visible. see sluggish ui because ui thread used/abused perform kinds of work not related ui updates.

in swing, there 1 thread on may update ui, , same thread responsible painting ui (the event dispatch thread). if block thread e.g. performing calculations on it, ui not able repaint or react on user input while calculation running. why must perform heavy work on worker thread. explained in concurrency in swing tutorial.

not 100% sure happening in case, sounds it. if want sure, take thread dump while waiting ui , see thread named awt-eventqueue-0 doing @ moment. if takes 5 minutes before ui updated, must able locate blocking ui.

java performance swing jtabbedpane miglayout

No comments:

Post a Comment