Code covered by the BSD License  

Highlights from
Progress bar

5.0

5.0 | 3 ratings Rate this file 37 Downloads (last 30 days) File Size: 9.98 KB File ID: #26773
image thumbnail

Progress bar

by

 

23 Feb 2010 (Updated )

An elegant and easy-to-use progress bar dialog utilizing the Swing GUI class JProgressBar.

| Watch this File

File Information
Description

The progress bar can be displayed and manipulated using two approaches.

In the procedural style, the function waitdialog wraps the Java Swing GUI class JProgressBar for enhanced visual experience but is functionally similar to the built-in function waitbar.

In the object-oriented style, ProgressDialog is a class that encapsulates a progress bar created using the waitdialog function, provides get/set access to the status message text and the progress indicator, and ensures proper cleanup on user interruption either using the cancel button or CTRL+BREAK, as well as in case an error occurs.

EXAMPLE

% show progress bar dialog
dlg = ProgressDialog();

maxiter = 50;
for iter = 1 : maxiter
    % do any long-running operation
    pause(0.1);
    
    % update progress bar
    dlg.FractionComplete = iter/maxiter;
    
    % update status message
    dlg.StatusMessage = sprintf('%d%% complete', fix(100*iter/maxiter));
end

% destroy progress bar dialog explicitly
delete(dlg);

% create progress bar dialog with custom status message
dlg = ProgressDialog( ...
    'StatusMessage', 'Please wait until operation terminates...', ...
    'FractionComplete', 0.25);
pause(2);

% hide status message
dlg.StatusMessage = [];
dlg.FractionComplete = 1;
pause(2);

% create progress bar with indeterminate state
% previous dialog is automatically destroyed on assignment
dlg = ProgressDialog( ...
    'StatusMessage', 'Close the dialog to continue', ...
    'Indeterminate', true);
uiwait(dlg);

Acknowledgements

Using Java Swing Components In Matlab inspired this file.

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
08 Mar 2013 Gustavo Betancourt  
07 Apr 2010 Abe Lau

Thanks Levente.

This is a really nice improvement over the built-in waitbar. The option with indetermine state (just a moving bar, and is always MOVING) is especially useful, in cases of a single slow command. The default waitbar will just freeze and doesn't give any feedback!

24 Mar 2010 Gökhan Vural  
Updates
24 Feb 2010

n/a

13 Mar 2010

Added indeterminate state; removed external dependencies.

Contact us