Code covered by the BSD License  

Highlights from
statusbar

4.88889

4.9 | 9 ratings Rate this file 67 Downloads (last 30 days) File Size: 4.93 KB File ID: #14773
image thumbnail

statusbar

by Yair Altman

 

25 Apr 2007 (Updated 13 Oct 2011)

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

| 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.

Technical description:
    http://UndocumentedMatlab.com/blog/setting-status-bar-text
    http://UndocumentedMatlab.com/blog/setting-status-bar-components

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
This submission has inspired the following:
Tabular Expression Toolbox

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 (21)
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 !

28 Jan 2010 Squall Mania

It works like a charm! I have inserted the progress bar on my figure and it worked perfectly. I have one question, is it possible to actually change the position of the progress bar on my figure? I want it to be up and below my pushbutton.

Your help would be greatly appreciated!
Thanks again.

28 Jan 2010 Yair Altman

It is not possible to modify the statusbar's position. But you can use the TooltipWaitbar utility that does what you wanted: http://www.mathworks.com/matlabcentral/fileexchange/26284-tooltip-waitbar

Yair

28 Jan 2010 Squall Mania

Thanks for the quick reply. I appreciate it.

06 Apr 2010 Alex

Great tool! One request for assistance:
In my GUI I need to load a different figure each time I press a button; the figure should contain a statusbar. However the statusbar is loaded only in the first figure.

Any ideas?
Thanks

06 Apr 2010 Yair Altman

Alex - in your button callback, after you create the new figure, pass its handle as the first input argument to the statusbar utility. If you don't, statusbar uses gcf (the current figure handle) which is still pointed to your original figure.

08 Apr 2010 Alex

Indeed, the correct handle is the solution. Thanks for the prompt response Yair.

29 Mar 2011 Danilo Zanatta

First, thanks for the nice tool!!!!

Just to report a warning in R2010b:

Warning: Possible deprecated use of set('Visible','off') on Java boolean property:
use jobj.setVisible(false) instead.

Fixed by changing line 229 of statusbar.m to:

jProgressBar.setVisible(false);

12 Jun 2011 Kesh Ikuma

Yair, thanks for another great one!

I spotted a minor bug (well, I wouldn't even call it a bug, more of an annoyance).

If you run "statusbar(gcf,'test')" twice, the second call displays 3 "ans" in Command Window. They all say "ans = Property name already in use."

12 Jun 2011 Kesh Ikuma

Found another bug.

fig = figure('Visible','off');
statusbar(fig,'test');

errors out in the setFigureStatus subroutine. I guess that the figure is not instantiated yet if it's made invisible at the time of creation.

13 Jun 2011 Yair Altman

Kesh - all Java-based functionality in Matlab (not just this StatusBar utility) requires the figure window to be visible and fully-rendered.

To remove the 'Property name already in use' annoyance, simply put a comment (%) at the beginning of line #263 (lasterr). This has no effect on the functionality.

05 Jul 2011 Danilo Zanatta

Matlab 7.10.0 (R2010a) and later versions give me the following warning:

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

Any chance this can be "fixed"?

Thx!

13 Oct 2011 Yair Altman

@Danilo - the updated version that I uploaded today hides the warning. It should be available here shortly (maybe tomorrow).

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

13 Oct 2011

Fix for R2011b

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
example Gordon 14 Oct 2010 02:42:16
example salamay 05 Jan 2011 19:09:43
example Dan Choen 19 Oct 2011 10:56:01

Contact us at files@mathworks.com