Hi All,
I've hit a point in my app when I first call .validate() when loading a
new panel (it is fairly complex), it takes up to 5 seconds to load..
There must be something I can do to get over this and was wondering if
anyone had any ideas, if you are interested then my App flows like this..
A quite simple frame is initially created and displayed to user, this
contains a button with 4 buttons, a BIG panel and a menu bar and thats
it for now. the button bar is on left, menu at top and the Panel taking
everything else up..
When the user clicks a button, an appropriate panel is then called and
'loaded into' the big empty space where the panel is. All this is in a
function called Show() which is as follows...
private void show(Component component) {
java.awt.GridBagConstraints gridBagConstraints;
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
Main.removeAll();
Main.add(component,gridBagConstraints);
this.validate();
}
when a button is clicked, depending on the button I call the show
command like this...
show(new divelog.forms.ProfilePanel());
The panel that gets loaded that I have a problem with containt 3 panels
in a tabpanel. each one of those has a table, and maybe 10 textfields
per panel.
So not really all that much complexity I dont think, the instantiation
of the panel doesnt take long, so setting up the listeners I have seems
ok its just the moment the .validate() line is executed there is the 5/6
second delay.
Anyone any ideas ? I was thinking Ok I'll create the instances of the
panels in a seperate thread, but as I said the creation doesnt really
take anytime at all.
Thanks in advance.
--------------------
Rgds,
Dave.
Thomas Weidenfeller - 26 Jul 2005 08:22 GMT
> I've hit a point in my app when I first call .validate() when loading a
> new panel (it is fairly complex), it takes up to 5 seconds to load..
Attach a profiler to the application and measure where the 5 second
delay happens. Once you know where it happens optimize that part.
Guesses about a performance bottleneck are almost always wrong. Even
programmers with decades of experience usually get those guesses wrong.
You have to measure it.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Dave Brown - 26 Jul 2005 09:41 GMT
Hi,
I used JProfiler and tracked it down to the .validate() line.
Rgds,
Dave
>> I've hit a point in my app when I first call .validate() when loading
>> a new panel (it is fairly complex), it takes up to 5 seconds to load..
[quoted text clipped - 7 lines]
>
> /Thomas
Thomas Weidenfeller - 26 Jul 2005 09:48 GMT
> Hi,
>
> I used JProfiler and tracked it down to the .validate() line.
Drill down more to figure out what's going on inside. E.g. validate will
for sure at some time invoke the layout managers.
BTW, and please stop top-posting.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Dave Brown - 26 Jul 2005 15:19 GMT
Thanks for the pointer Thomas, JPRofiler was set to ignore java.* calls
so I couldnt see further than the .validate call. After going down the
tree further I noticed that theres some font loading going. Soo when I
changed from tahoma back to ms sans serif for my JLabels it made a world
of difference !
Seems swing doesnt perform to good when loading TTF's. Think I'll leave
the fonts as default from now on.
Rgds,
Dave.
>> Hi,
>>
[quoted text clipped - 6 lines]
>
> /Thomas