Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why is this code taking too long to launch

 
Amr Hesham
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are your system specs? On my system the program starts in two seconds.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Amr Hesham
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried debugging the program, and it seems that is the line causing the slowness. Any ideas?
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic