4.8

4.8 | 5 ratings Rate this file 289 downloads (last 30 days) File Size: 11.73 KB File ID: #14773

statusbar

by Yair Altman

 

25 Apr 2007 (Updated 04 May 2007)

No BSD License  

set/get status bar(s) for GUI figures & Matlab desktop

Download Now | Watch this File

File Information
Description

statusbar sets the status-bar text of the Matlab desktop or a figure. statusbar accepts arguments in the format accepted by the sprintf function and returns the statusbar handle(s), if available.

Syntax:
    statusbarHandle = statusbar(handle, text, sprintf_args...)

statusbar(text, ...) sets the status bar text for the currently selected figure. If no figure is selected, then one will be created. Note that figures with 'HandleVisibility' turned off will be skipped. In these cases, simply pass their figure handle as first argument.

statusbar(handle, ...) sets the status bar text of the figure handle (or the figure which contains handle). If the status bar was not yet displayed for this figure, it will be created and displayed. If text is not supplied, then any existing status bar is erased, unlike statusbar(handle, '') which just clears the text.

statusbar(0, ...) sets the Matlab desktop's status bar text. If text is not supplied, then any existing text is erased, like statusbar(0, '').

statusbar([handles], ...) sets the status bar text of all the requested handles.

statusbarHandle = statusbar(...) returns the status bar handle for the selected figure. The Matlab desktop does not expose its statusbar object, so statusbar(0, ...) always returns []. If multiple unique figure handles were requested, then statusbarHandle is an array of all non-empty status bar handles.

Notes:
1) The format statusbarHandle = statusbar(handle) does NOT erase any existing statusbar, but just returns the handles.
2) The status bar is 20 pixels high across the entire bottom of the figure. It hides everything between pixel heights 0-20, even parts of uicontrols, regardless of who was created first!

Examples:
> statusbar; % delete status bar from current figure
> statusbar(0, 'Desktop status: processing...');
> statusbar([hFig1,hFig2], 'Please wait while processing...');
> statusbar('Processing %d of %d (%.1f%%)...',idx,total,100*idx/total);
> statusbar('Running... [%s%s]',repmat('*',1,fix(N*idx/total)),repmat('.',1,N-fix(N*idx/total)));
> existingText = get(statusbar(myHandle),'Text');

Examples customizing the status-bar appearance:
> sb = statusbar('text');
> set(sb.CornerGrip, 'visible','off');
> set(sb.TextPanel, 'Foreground',[1,0,0], 'Background','cyan', 'ToolTipText','tool tip...')
> set(sb, 'Background',java.awt.Color.cyan);

Warning:
  This code heavily relies on undocumented and unsupported Matlab
  functionality. It works on Matlab 7+, but use at your own risk!

Bugs and suggestions:
  Please send to Yair Altman (altmany at gmail dot com)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
FindJObj - find java handles of Matlab graphic objects, UICOMPONENT - expands uicontrol to all Java classes

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Tested on Matlab 6.0-7.4. In Matlab 6.0 (R12) figure statusbars are not supported - only desktop statusbar. Please report any other compatibility issues.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
04 Jun 2007 Darik Gamble

This is fantastic. Very clean implementation.

One question: is there a way to turn off the entire statusbar visibility without destroying it or setting the child visibilities?

05 Jun 2007 Yair Altman

You can control statusbar visibility without destroying it as follows: statusbarHandle.getParent.setVisible(0); %0/1

09 Aug 2007 Marcus Gualtieri  
11 Mar 2008 Ralf Hielscher

Straight forward to include and very nice!

11 Dec 2008 Kim

i can't seem to get it working... i want to implement it in a GUI, but how en where do i place what?
Please help!

06 Apr 2009 Hoi Wong

Great tool. My project uses a lot of your enableDisableFig and stausbar. But it seems like R2009b pops out a lot "Property name already in use" and MCR pops out a lot problems with 'undefined function or variable currentState' in enableDisableFig. Got some time to look at it? Thanks!

24 Jul 2009 Stefano Gianoli

Very nice implementation. Though I receive this warning message.:

Warning: figure JavaFrame property will be obsoleted in a future release. For more information see the JavaFrame
resource on the MathWorks Web site.
> In statusbar>setFigureStatus at 202
  In statusbar at 148

I am using MATLAB Version 7.6.0.324 (R2008a)

Is there an alternative to JavaFrame function that will be supported in future releases?

24 Jul 2009 Yair Altman

JavaFrame has no alternative. If and when it is discontinued in some future version we shall try to look for alternatives. Until then simply ignore this error by typing:

warning off MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame

Note that even if some future version discontinues JavaFrame, it will still continue to work properly on all prior Matlab versions (including your current version).

If you find JavaFrame to be useful for your needs, please consider letting MathWorks know about this in the webpage they dedicated for just this purpose:

http://www.mathworks.com/support/contact_us/dev/javaframe.html

08 Oct 2009 Aurelien Queffurust

Tested in R2009b, it works perfectly, the function is really well documented . I used all the customization (toollip, background ...)
It is very good to have a waitbar "docked". Thanks !

Please login to add a comment or rating.
Updates
30 Apr 2007

Added internal ProgressBar; clarified main comment

04 May 2007

Added partial support for Matlab 6

Tag Activity for this File
Tag Applied By Date/Time
gui tools Yair Altman 22 Oct 2008 09:10:32
example Yair Altman 22 Oct 2008 09:10:32
statusbar desktop java Yair Altman 22 Oct 2008 09:10:32
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com