in need of swing performance advice



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.
.


Quantcast