Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sluggish GUI  RSS feed

 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone.

I've a GUI program with a few frames(MainUI,2ndUI,3rdUI,4thUI). Each frames containing a few images(background image, buttons image, title image,etc..).

During the running of program, the UI seems sluggish at loading. Is there any ways that I can improve the efficiency of my java program?

While I was trying to solve this problem, I saw a few threads about Multi threading. However, I'm not confident if It could work in my program. Compared to the examples given by others, my program only responds to key press and will make changes to the UI accordingly.

Can anyone advice me please.
[ July 25, 2007: Message edited by: Adrian Lee ]
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, if the sluggishness is at loading I would try walking the datasets several times in the constructor.

Threads can be exciting as a solution to the problem you describe. David Eck has a website with several applets that run effectively, but then he holds a chair at a university teaching the stuff.

In general, the first place to look is whether you have put all the executing code in the paint methods - there are several names already and these tend to get trendy as times change and JDK's move forward, I am sure that by now putting exec code in paint methods will be depreciated rather than just changing some names around.

Another approach is just to use the latest releases of jdk and pre-written classes, I am sure the OO Board of the Saloon Wall will resonate this approach.

For a general discussion in overview, see steve souza's post Saturday, September 10, 2005 some random thoughts in no particular order: which is about halfway down the page and is pulled out for inspection in an FAQ at General tips and guidelines for tuning code This is a really good overview of your problem.
[ July 29, 2007: Message edited by: Nicholas Jordan ]
 
Adrian Lee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nicholas
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My suggestions are:
1 Make the UI staff done in EDT(Event-Dispatch-Thread).
2 Make the IO staff(load pictures in your case) done in a worker thead.

You should have a look at Swingworker. If you are using JDK1.6, it's already there, just use it!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!