Home arrow static arrow Java Programming [Archive] - opening new frame -- performance
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - opening new frame -- performance
This topic has 5 replies on 1 page.

Posts:13
Registered: 12/14/01
opening new frame -- performance  
Jul 30, 2004 10:24 AM



 
I am having an issue in my application where the creation and displaying of a new JInternalFrame is taking 1-2 seconds. Basically, the user clicks a button on an existing JInternalFrame inside of the JDesktopPane and that in turn will open a new JInternalFrame. I want the new frame to pop up instantly, not take 1-2 seconds.

I used the JProfiler software to determine where the CPU is getting hogged up and the only bottleneck I see is the java.awt.EventDispatchThread at 2847ms (67% CPU usage). But I do not get any more detail. I am looking at my code for the JInternalFrame and the code is very simple and short.

1. Any idea on what is the bottleneck, is this just typical java when creating a new JInternalFrame? I have created "test" programs that mimic this and i notice there is a slight lag in the new window showing up.
2. Is there a better software to diagnose this than JProfiler?
3. How can I improve performance of opening a new JInternalFrame? I have considered opening 5-10 hidden JInternalFrames at "startup" and then modifying its contents and displaying them, but this gets tricky because I will have to play with a lot of changes (i use Window Arrangers and other things right now)

any advice would help and is appreciated
 

Posts:14,142
Registered: 99-04-02
Re: opening new frame -- performance  
Jul 30, 2004 11:08 AM (reply 1 of 5)



 
Well, the things to look at first, IMO, are the following:

1) What else is happening when you click on the button that opens the new frame? Are you saying "new frame" and then doing several other things after that within that event handler? Cuz if so, the "other things" are adding to the delay, since the handler for the button press is in the event thread and the GUI will not update til it's finished.

2) What are you putting in the frame? Are you having some complicated GUI or loading something from somewhere when when you construct the frame before you show it? Cuz that could be taking time too.
 

Posts:13
Registered: 12/14/01
Re: opening new frame -- performance  
Jul 30, 2004 2:52 PM (reply 2 of 5)



 
1. I (a) setFrameIcon (image already loaded in memory), (b) set frame size and location, (c) add some text and textfields using gridbaglayout (maybe 10 components total, nothing fancy, (d) bring it to the front
2. Nothing complicated, just a small gridbaglayout.

then control returns of course to the parent frame which then adds this newly created frame to the JDesktopPane and then brings it to the front.

do you know a software that is better than JProfiler that will show me more details on exactly what lines of source the CPU usage is at? that might help diagnose.

thanks for your help. if you have any other suggestions, please let me know.

Well, the things to look at first, IMO, are the
following:

1) What else is happening when you click on the
button that opens the new frame? Are you saying "new
frame" and then doing several other things after that
within that event handler? Cuz if so, the "other
things" are adding to the delay, since the handler for
the button press is in the event thread and the GUI
will not update til it's finished.

2) What are you putting in the frame? Are you having
some complicated GUI or loading something from
somewhere when when you construct the frame before you
show it? Cuz that could be taking time too.
 

Posts:14,142
Registered: 99-04-02
Re: opening new frame -- performance  
Jul 30, 2004 3:26 PM (reply 3 of 5)



 
Hmm... not sure then... OptimizeIt, or JProbe are supposed to be good, but I've never actually used them.
 

Posts:447
Registered: 3/8/01
Re: opening new frame -- performance  
Jul 30, 2004 3:56 PM (reply 4 of 5)



 
Are the JDesktopPane demos in the SDK (in SwingSet2 probably) also this slow? If not, it's a problem with something you're doing. Try finding it step by step. First just create a frame. Then create a frame and set the layout. Then load your text. Then set the icon. Etc. See which step is a problem.
 

Posts:24,517
Registered: 98-02-27
Re: opening new frame -- performance  
Jul 31, 2004 12:09 PM (reply 5 of 5)



 
Have you run the demo from the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html]How to Use Internal Frames[/url]. It creates an internal frame almost instantaneously, so it must be the components you are adding to the frame that are the problem.
 
This topic has 5 replies on 1 page.