This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing GUI formatting problem

 
Norm Radder
Ranch Hand
Pie
Posts: 1031
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I normally use AWT for my program's GUI since they mostly have simple user input. For my current project I decided to use Swing. The program is for capturing the stats for Duplicate Bridge. It has a spread sheet style layout with about 20 rows consisting of labels,text fields and radio buttons to hold the data for each hand played.

My problem: when openning (File|Open>..) previously saved data, the window/scroll pane underneath the dialog window for choosing the file to open is cleared and then repainted very SLOWLY.

What can I do to speed up/eliminate the slow repainting?

A version of this program is at: http://users.mo-net.com/normandpaula/DuplicateScorer.jar

I'm using Java 1.5 in Windows XP on a 1.3GHz system.

Thanks,
Norm
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post some of the code that gets called when a file is opened?

It might be an issue of performing all the processing in the event thread - here's an article about using Threads in Swing.

I tried to test it by running your linked program, but I am also having problems saving... whenever I fill in any data in the form, then press 'Save As...' or 'Save' it throws a NullPointerException before the save dialog is launched. Do all the cells have to be filled in before saving?
 
Norm Radder
Ranch Hand
Pie
Posts: 1031
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nate,
thanks for the response.
Yes it was a case of using the wrong thread. I moved the code that reads the file to its own thread and the time for the empty spot to be repainted is acceptable.

Re the null pointer exception: I've since made several other changes to the program and uploaded the new version. Could you please send me a copy of the .log file that shows the tracelog for the exception?

Thanks,
Norm
 
Norm Radder
Ranch Hand
Pie
Posts: 1031
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Re filling in all the fields: The program is supposed to force you to fill in all the fields on any single line. But you don't have to fill in more than one line for any hand.

Norm
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic