my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Why is this code taking too long to launch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Why is this code taking too long to launch" Watch "Why is this code taking too long to launch" New topic
Author

Why is this code taking too long to launch

Amr Hesham
Greenhorn

Joined: Jun 20, 2010
Posts: 8
This is the code for a simple text editor in Java. The GUI components are from the swing library; however, the program takes around 10 seconds to start up! Does anybody know why this is happening?

Mike Peters
Ranch Hand

Joined: Oct 10, 2009
Posts: 67

What are your system specs? On my system the program starts in two seconds.


Mike Peters
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

I'm not saying that it's the cause of the slow startup, but in general you should always construct and manipulate Swing components only on the EDT and not in the main thread.Also, by convention all Java class names start with an uppercase letter.


luck, db
There are no new questions, but there may be new answers.
Amr Hesham
Greenhorn

Joined: Jun 20, 2010
Posts: 8
I've tried debugging the program, and it seems that is the line causing the slowness. Any ideas?
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Amr Hesham wrote:I've tried debugging the program, and it seems that is the line causing the slowness. Any ideas?

??
I don't see that line of code anywhere in your posted program.
Amr Hesham
Greenhorn

Joined: Jun 20, 2010
Posts: 8
Sorry, I meant


I've also noted that


was making the program's launch slow (with the panel.add(scroller) commented out), but I managed to fix that by removing this line and adding the initialization to the variable declaration before main.
 
 
subject: Why is this code taking too long to launch