aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Best practise for displaying live log files in swing 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 "Best practise for displaying live log files in swing" Watch "Best practise for displaying live log files in swing" New topic
Author

Best practise for displaying live log files in swing

Kris Massey
Greenhorn

Joined: Mar 26, 2009
Posts: 12
Hey guys,

Ive come across a problem and Im not sure about the best way to proceed...

I need to display the progress of a large background process...I know the swing worker will allow me to update the UI live without threading issues...but Im un sure what component would be the best to use, mainly for overhead. My thinking is to use a JList and then append a new line to the end of a List Model...but Im not a hardcore Swing developer and was wondering if there is a preferred method of doing this? Below is a little more detail...

So are are going to be processing in the region fo 200,000 files and each one needs to be placed into the To Do list first off which needs to be displayed and then moved to the processed list once it has been completed. My thinking is that if we load everything into the to do list (JList) at the start then we can simply remove them and add them to the processed list (JList) once they have been completed...my worried lay around the ability of a JList to contain 200,000 records and then be modified live, will this cause the GUi to take loads of resources and the underlying process will need as much CPU as it can get to complete the job quickly....

Hope Ive made what Im trying to do clear any comments would be great as Im a bit of a novice when it comes to developing multi thread Swing apps...


Cheers in advance
Kris
Eric Mission
Greenhorn

Joined: Apr 22, 2009
Posts: 22
This is what I see in your post...

Requirement 1:
I need to display the progress of a large background process

Requirement 2:
each one needs to be placed into the To Do list

Requirement 3:
then moved to the processed list once it has been completed


So, you are going to have 3 lists- one showing the ToDo, completed, and currently running process.

I would load the file names or whatever it is that needs to be displayed in the todo list 10 or 20 at a time and the same with the completed list. Depending on the file size and what kind of processing is going on, you may complete the background process before the list is ever populated (simulated race condition) at 200,000 lines. After processing 20 files or so I would save the completed list to a flat file, XML file or similar in case something happened to the app, that way you could have a reference to look up to determine the last file processed. This would prevent displaying 200,000 records in a list.

Think of it like a baseball game where you have players in the dugout (todo), players on the bases (completed), players on deck (currently run process) and the scoreboard as your record keeper.

Hope that helps.


to infinity and beyond
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best practise for displaying live log files in swing