Undocumented Matlab
  • SERVICES
    • Consulting
    • Development
    • Training
    • Gallery
    • Testimonials
  • PRODUCTS
    • IQML: IQFeed-Matlab connector
    • IB-Matlab: InteractiveBrokers-Matlab connector
    • EODML: EODHistoricalData-Matlab connector
    • Webinars
  • BOOKS
    • Secrets of MATLAB-Java Programming
    • Accelerating MATLAB Performance
    • MATLAB Succinctly
  • ARTICLES
  • ABOUT
    • Policies
  • CONTACT
  • SERVICES
    • Consulting
    • Development
    • Training
    • Gallery
    • Testimonials
  • PRODUCTS
    • IQML: IQFeed-Matlab connector
    • IB-Matlab: InteractiveBrokers-Matlab connector
    • EODML: EODHistoricalData-Matlab connector
    • Webinars
  • BOOKS
    • Secrets of MATLAB-Java Programming
    • Accelerating MATLAB Performance
    • MATLAB Succinctly
  • ARTICLES
  • ABOUT
    • Policies
  • CONTACT

Changing Matlab's Command Window colors

March 19, 2009 59 Comments

Yesterday I received an email asking if it was possible to programmatically change Matlab’s Command Window foreground and background colors. This is possible from the File/Preferences window, but requires interactive user actions. The question was whether it was possible to do so programmatically, in order to place the necessary commands in some script (for example, startup.m). This is important, for example, when we have two Matlab applications open at the same time and wish to visually distinguish between them.
After getting this email, one in a long list of similar questions I tackled over the past few years regarding Matlab’s undocumented/unsupported/hidden features, I decided it was time to start a blog on this broad subject. I do not know if there is any interest in the subject of this blog, so I would be extremely happy to hear feedback.
Changing Command-Window colors can be done programmatically in two manners: The first is by modifying system preferences. The issue of programmatic access to system preferences is detailed in another dedicated post. Here is the bottom line regarding the colors:

% Don't use system color
com.mathworks.services.Prefs.setBooleanPref('ColorsUseSystem',0);
% Use specified colors for foreground/background (instead of the default black on white)
com.mathworks.services.Prefs.setColorPref('ColorsBackground',java.awt.Color.yellow);
com.mathworks.services.ColorPrefs.notifyColorListeners('ColorsBackground');

% Don't use system color com.mathworks.services.Prefs.setBooleanPref('ColorsUseSystem',0); % Use specified colors for foreground/background (instead of the default black on white) com.mathworks.services.Prefs.setColorPref('ColorsBackground',java.awt.Color.yellow); com.mathworks.services.ColorPrefs.notifyColorListeners('ColorsBackground');

and similarly for the foreground color, whose property name is called ‘ColorsText’. Note that colors can be specified in several alternative manners (see below).
This affects all Matlab text panes (Command Window, Command History, Workspace Browser etc.), for this and all future Matlab sessions. If you only wish to set the colors in the command window and not in all the other Matlab text panes, or if you only wish to modify this session, then forget the prefs method. Instead, simply use the following short code snippet (you may need to tweak it for particular Matlab versions) to change the colors of only the command text pane (that’s a Swing JTextArea, for those of you who are java-savvy).

cmdWinDoc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance;
listeners = cmdWinDoc.getDocumentListeners;
jTextArea = listeners(3);  % or listeners(4) or listeners(5), depending on Matlab release

cmdWinDoc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance; listeners = cmdWinDoc.getDocumentListeners; jTextArea = listeners(3); % or listeners(4) or listeners(5), depending on Matlab release

Note: a safer way would be to loop on listeners until finding a JTextArea instance, since it is not assured to be the 3rd item in the listeners array.
Now you can set the colors (which apply immediately) using several alternative ways:

jTextArea.setBackground(java.awt.Color.yellow);
jTextArea.setBackground(java.awt.Color(1,1,0));
set(jTextArea,'Background','yellow');
set(jTextArea,'Background',[1,1,0]);

jTextArea.setBackground(java.awt.Color.yellow); jTextArea.setBackground(java.awt.Color(1,1,0)); set(jTextArea,'Background','yellow'); set(jTextArea,'Background',[1,1,0]);

You can do the same with the ‘Foreground’ property.
Please let me know what you think of this post, or of this blog in general. Your feedback, as well as additional questions and suggestions are most welcome.
Yair Altman
altmany at gmail dot com

Related posts:

  1. Changing Matlab's Command Window colors – part 2 – The Matlab Command Window enables a limited degree of inline color customization - this post describes how to use it...
  2. Bold color text in the Command Window – Matlab Command Window text can be formatted *bold* since R2011b. ...
  3. EditorMacro v2 – setting Command Window key-bindings – The EditorMacro utility was extended to support built-in Matlab Editor and Command-Window actions and key-bindings. This post describes the changes and the implementation details....
  4. cprintf – display formatted color text in the Command Window – cprintf is a utility that utilized undocumented Matlab desktop functionalities to display color and underline-styled formatted text in the Command Window...
  5. Another Command Window text color hack – Matlab's fprintf command has an undocumented hack to display orange-colored text. ...
  6. Command Window text manipulation – Special control characters can be used to format text output in Matlab's Command Window. ...
Desktop Java
Print Print
Next »
59 Responses
  1. Ben S March 22, 2009 at 16:05 Reply

    Yair

    Thanks for addressing this point.

    In response to your question of is there an interest in undocumented/unsupported/hidden matlab features? YES, yes, and yes again.

    I look forward to reading and learning.

    If I come across other non trivial issues I will be sure to post here as well (it might attract your attention quicker than Matlab Central?!)

    take it easy
    Ben

    • Yair Altman March 22, 2009 at 17:14 Reply

      Thanks for your feedback Ben – you are my first and as yet only commentator, so at least I know I’m not writing in a vacuum… 🙂

      Dear readers – the more feedback I receive, the better I will be able to tune this blog into something that is interesting to you. So, if you have any preference at all, please leave a reply or shoot me an email (altmany at gmail), about anything: the length of my posts, how detailed you want to see the code snippets, whether you’re more interested in Java internals or undocumented features in plain Matlab functions – anything at all. I’ll do my best to accommodate your wishes and make this blog as interesting as possible,

      Yair

  2. Sid H March 23, 2009 at 02:30 Reply

    Good work. I expect your work goes more into extending the capability of the gui and interface programming; My only thought is that matlab is a child to the windows shell environment and should have inherited all the .net properties/attributes too. So your stuff is a step in the right direction.

    Right now I am looking at generating (simple) dynamic html scripts using matlab guis to report collected data, don’t suppose you know of someone who’s done that already and published a collection of functions of that type. I know about the report generation feature that matlab has, but it’s customizability sucks and it does not handle all the data types very well.

    Best of luck and regards

    Sid

  3. Ben S March 25, 2009 at 15:00 Reply

    Hi Yair

    I saw that memory monitor is on the TODO list.

    At the risk of being selfish(!), here is another suggestion. One of my frustrations concerns the memory management. I’m using release 2007b so maybe it improved in later versions anyway. However if not, here’s a brief description:

    “feature(‘memstats’)” gives me the size of the largest contiguous free block. This limits the maximum size of a variable I can use.
    As I run code & create variables the largest free block will only ever decrease in size. “clear”, “clear global”, “java.lang.System.gc” will clear variables and memory but appears not to increase the size of the largest free block. It is as if the memory is lost. Eventually, i quit and restart Matlab to start with a decent sized largest free block.

    So my question is (if you feel inclined) is their a nifty way to “give back” the memory, increase the size of the largest free block and avoid having to quit?

    all the very best
    Ben

    • Yair Altman March 27, 2009 at 08:38 Reply

      Ben – in response to your question: I was able to recreate your predicament and nothing I tried worked, just like you said 🙁
      This is actually a great topic to investigate since it stands to reason that there’s a Java hack somewhere to pack the memory.
      I’ll keep trying new ideas and if I come across something I’ll let you know.

      Yair

  4. Peter Navé March 27, 2009 at 07:14 Reply

    Hello,
    I found your recipe for changing the background color of the command window very helpful. I have been looking for such an instruction for quite some time because I think that a tinted screen is easier on the eyes than white.
    Thank you and best wishes,
    Peter Navé
    2009-03-27

  5. shabby April 3, 2009 at 10:33 Reply

    I stumbled on matlab’s save stdio feature recently; only appears to work with -nodesktop mode?

    matlab -r ‘x = rand(5,1);save stdio x;exit’ -nodesktop

  6. cprintf - display formatted color text in the Command Window | Undocumented Matlab May 13, 2009 at 06:26 Reply

    […] In earlier posts I showed how to modify the Command Window (CW) text and background color, and a very limited method of displaying red (error) and blue (hyperlinked) CW messages. […]

  7. Changing Matlab’s Command Window colors - part 2 | Undocumented Matlab May 13, 2009 at 06:35 Reply

    […] Following my post on Changing Matlab’s Command Window colors, I received an email asking whether it was possible to temporarily set the Command-Window text color […]

  8. Changing system preferences programmatically | Undocumented Matlab June 17, 2009 at 13:58 Reply

    […] My very first post on this blog showed how to change Matlab’s command-window colors. In that post I promised to write another post detailing how system preferences can be changed […]

  9. Tal K August 4, 2009 at 01:57 Reply

    Hi Yair.
    First of all, the undocumented Matlab stuff is very helpful, and it seems like you are a wizard in this field.
    In regard to this post, I have a different (yet related) inquiry.
    When creating a GUI programatically, I can select my GUI’s colors using the uicontrol property “BackgroundColor” and the figure property “Color”.
    However, I have encountered two annoying things:
    1. I cannot set the uimenu background color (it is system set)
    2. When creating a slider uicontrol, I can set the background color, but not the slider button itself and the arrow up/down buttons.

    Wanted to know whether you know how to do this.

    Thanks in advance, and keep doing this unusual and great service for the Matlab community.
    Tal.

    • Yair Altman August 4, 2009 at 03:28 Reply

      Thanks Tal 🙂

      1. uimenu background, font, icon, alignment etc. can be set by accessing the Java handle of the Matlab object. I plan to do an extensive post on this issue sometime soon. In the meantime, use my FindJObj utility on the Matlab File Exchange to view/get this handle:

      hmenu = uimenu(...);
      jmenu = findjobj(hmenu);
      set(jmenu, 'Background', java.awt.Color.yellow);
      jmenu.setBackground(java.awt.Color(1,0.8,0));  % alternative
      set(jmenu,'ToolTipText','something or other...');  
      % etc. for other properties

      hmenu = uimenu(...); jmenu = findjobj(hmenu); set(jmenu, 'Background', java.awt.Color.yellow); jmenu.setBackground(java.awt.Color(1,0.8,0)); % alternative set(jmenu,'ToolTipText','something or other...'); % etc. for other properties

      2. See my previous paragraph vis-a-vis FindJObj. In practice though, this is more difficult: the arrows are pre-configured (painted in runtime on top of two small button sub-components); I don’t know how to modify the slider button color – search the web for “change JScrollBar color”, since Matlab sliders are basically simple Java JScrollBar objects.

      Yair

      • Tal K August 4, 2009 at 23:42

        Hi Yair.
        Thanks for your prompt reply.
        As I am working with Matlab 7.0.4 (my fault, I know…), findjobj() is encountering all kinds of compatibility problems. I might try to debug it sometime.
        Anyway, I will be looking forward for your next posts.

  10. Cameron Bracken December 7, 2009 at 18:45 Reply

    Is it possible to set background transparency?

    • Yair Altman December 8, 2009 at 01:02 Reply

      Cameron – I don’t think you can set the bg transparency

    • Yair Altman April 13, 2011 at 16:30 Reply

      Take a look at this recent blog article: http://undocumentedmatlab.com/blog/transparent-matlab-figure-window/

  11. Sitha December 24, 2009 at 18:49 Reply

    Could you provide code underline text in matlab?

    • Yair Altman December 25, 2009 at 02:51 Reply

      You can underline Matlab Command-Window text using the CPRINTF utility, as described here: http://undocumentedmatlab.com/blog/cprintf

  12. Mimi June 30, 2010 at 05:37 Reply

    Hi, Thanks for this code!

    It works, except when I use the %% to divide parts of an m-file. The part that I want to modify still has a mother-of-pearl colored background ( I’d prefer it to be black.)

    How do I change this??

    Thanks again.

    • Yair Altman June 30, 2010 at 07:50 Reply

      @Mimi – I don’t understand. Please post the code that you are using.

  13. Egon July 5, 2010 at 08:35 Reply

    Is it possible to have MATLAB change the whole Desktop color scheme (so instead of these XP-colors on Linux, colors that are more like MATLAB on Mac?)

    I can’t seem to wrap my head around the needed Java methods to actually change the general UI.

    • Yair Altman July 7, 2010 at 09:43 Reply

      @Egon – see here

  14. Modifying Matlab's Look-and-Feel | Undocumented Matlab July 7, 2010 at 09:42 Reply

    […] A couple of days ago, a reader of this blog posted a comment, asking whether it is possible to change Matlab’s Desktop color scheme, and its general UI […]

  15. Jan April 11, 2011 at 12:18 Reply

    Hi,

    I’ve been trying to change the Title name string color to say green and the figure title bar color to say yellow so they match the company colors. Haven’t had much luck as neither is an option in Figure Properties. Did find that both follow the Windows Display Properties. Looked into the “matlab.prf” file but did not see any obvious fields to edit.

    Is it possible to edit the before mentioned colors?

    Thanks,

    Jan

    • Yair Altman April 11, 2011 at 12:36 Reply

      @Jan – I believe that the figure title bar colors cannot be modified without hacking into the underlying OS. This is because Matlab uses java to draw the figure window, and Java in turn uses the underlying OS to set the appearance.

      However, you can customize your Look-and-Feel if you are adventurous…

  16. Jakub September 19, 2011 at 02:17 Reply

    you saved my eyes, thanks

  17. Anubhav Jain September 20, 2011 at 08:59 Reply

    Hi,
    I am facing problem in hiliting a line that is not connected to any block.Can anyone suggest me a way to do that .
    Regards,
    Anubhav Jain.

  18. Raj December 1, 2011 at 11:54 Reply

    Hi,

    I ran the java commands as above. But only the color of the function browser (thin strip on the left side of the command window) changed. It became yellow and I couldn’t get it back to gray. So I had to change it to white. Maybe it is a compatibility issue with the new Matlab.

    I don’t know java so if you can help out in how to revert back to the original gray (light gray) color, that would be awesome.

    Also, isn’t the range of java.awt.Color from 0-255.
    Because gray is 211-211-211. And I am not able to enter that. Even 0.83 (211/255) didn’t work.

    I would appreciate any help.
    Thanks for the tutorial! 🙂

    • Yair Altman December 1, 2011 at 11:57 Reply

      @Raj – try java.awt.Color(0.827,0.827,0.827)

    • Raj December 1, 2011 at 12:12 Reply

      Hi Yair.. I just saw your reply.. Thanks for the help! :))

      Cheers!

  19. Raj December 1, 2011 at 12:11 Reply

    OK.. The following code worked:

    jTextArea.setBackground(java.awt.Color.lightGray);
    jTextArea.setBackground(java.awt.Color(.95,.95,.95));
    set(jTextArea,'Background','lightGray');
    set(jTextArea,'Background',[.95,.95,.95]);

    jTextArea.setBackground(java.awt.Color.lightGray); jTextArea.setBackground(java.awt.Color(.95,.95,.95)); set(jTextArea,'Background','lightGray'); set(jTextArea,'Background',[.95,.95,.95]);

    I was using "gray" instead of "lightGray".. :)
  20. Adam August 2, 2012 at 11:14 Reply

    Hi Yair,

    I’ve changed the background color of the matlab editor to black to go easy on the eyes when editing code, but I can’t seem to figure out how to change the cell mode background color to something darker. The light cell mode background color makes the white text ureadable. Any suggestions?

    • Yair Altman August 2, 2012 at 11:23 Reply

      @Adam – try a shade of dark gray for the cell mode bgcolor

  21. Ahmed October 29, 2012 at 00:38 Reply

    great work.

    i like to have a combination of eco-friendly colors, i mean to have the background in black (this would save some power as almost all pixels are turned off) then other colors that can let you see the text clearly , …

  22. Darik Gamble December 11, 2012 at 08:07 Reply

    Hi Yair,

    Do you know if it’s possible to change the font color and background of the editor’s line number column, or the column that shows the debugger breakpoints? I’ve been playing around trying to use this color scheme, and using the code on this page I’m able to set most of the relevant colors, but as you can see in this screenshot, it leaves the line numbers a really distracting color.

    Playing around with the com.mathworks.mde.desk.MLDesktop.getInstance.getGroupContainer(‘Editor’).getTopLevelAncestor handle in findjobj, I found a org.netbeans.editor.GlyphGutter object that seems to match, but changing its background color (or any other property) doesn’t appear anything.

    Any tips?

    Thanks!

    • Yair Altman December 11, 2012 at 08:54 Reply

      @Darik – I don’t know why the GlyphGutter object doesn’t update itself when you call its update() method (it should). Since org.netbeans.editor.* is an open-source package (part of the NetBeans project), you should find information on this in Java forums. If you find out, please post a follow-up comment here.

      Cross-reference #1: I discussed org.netbeans.editor.GlyphGutter briefly here, although it doesn’t answer this specific question.

      Cross-reference #2: The editor hierarchy for file panels appears to be (this varies with the Matlab release):

        - DTClientFrame
          - (lots of intermediate containers)
            - MJScrollPane
              - JViewport
                - EditorSyntaxTextPane
              - Scrollbar (vertical)
              - Scrollbar (horizontal)
              - JViewport
                - MJPanel
                  - GlyphGutter (line-numbers)
                  - MWCodeFoldingSideBar (code-folding widget)
                  - MJPanel
                    - BreakpointView$2 (breakpoints)
                    - ExecutionPanel (green arrow)
              - DragButton (top/bottom split)
              - DragButton (left/right split)
            - MJPanel
              - STPMessagePanel$3 (mlint/code-analyzer)
      
  23. leiguanqun January 8, 2013 at 20:10 Reply

    Your article is interesting. Can I also set a background image?

    • Yair Altman January 9, 2013 at 01:59 Reply

      @leiguanqun – You cannot set a background image easily. You would need to override the Java component’s paintComponent() or paint() methods, probably by creating a custom Java subclass and replacing the existing component with the new class object. In short, not easy if you’re not Java-savvy…

  24. Matlab Tip: Change the color-scheme to be easier on your eyes | Mike Soltys February 8, 2013 at 13:22 Reply

    […] final note: to change the colors via the terminal, you can use commands outlined in another cool MATLAB blog.  To get you started on the Solarized color scheme that I quite like, […]

  25. Mike February 8, 2013 at 13:30 Reply

    Hey, Great blog! I was trying to figure out a quick script to set all the colors on a computer with MATLAB to a scheme I prefer. You show how to change ‘ColorsText’ and ‘ColorsBackground’ but I’m wondering how to change other color preferences found in the system preferences dialog such as Keywords, Strings, Warnings, etc. A complete list of settable parameters would be awesome!

    • Yair Altman February 9, 2013 at 09:38 Reply

      @Mike – the following command opens the matlab.prf in the Editor, where you can easily see the names of all the different colors (search for ‘C-‘):

      edit([prefdir 'matlab.prf'])

      edit([prefdir 'matlab.prf'])

      Some of the available color names are:

      • Colors_HTML_HTMLLinks
      • Colors_M_Comments
      • Colors_M_Errors
      • Colors_M_Keywords
      • Colors_M_Strings
      • Colors_M_SystemCommands
      • Colors_M_UnterminatedStrings
      • CW_BG_Color
      • ColorsBackground
      • ColorsMLintAutoFixBackground
      • ColorsText
      • EditorRightTextLimitLineColor

      Note that the type names may change between Matlab releases, and the complete list may be different on your specific system.

  26. Ivan Klyuzhin March 14, 2013 at 16:21 Reply

    Hi Yair,

    Thank you for the useful post. I tried setting

    set(jTextArea,'Foreground',[1,1,1]);

    set(jTextArea,'Foreground',[1,1,1]);

    and the printed text turned white. However, the user-input text is still black. Here is a screenshot:
    https://dl.dropbox.com/u/7102252/Images/matlab-text-example.png

    Do you know if there is a way to change the color of the typed text?

    • Yair Altman March 14, 2013 at 16:33 Reply

      @Ivan – simply change the Text color in File=>Preferences=>Colors

      • Ivan Klyuzhin March 14, 2013 at 17:40

        Yair,

        The problem is that File=>Preferences=>Colors changes colors everywhere. What I am trying to achieve is to have white text on black background in the Command Window, but black text on white background everywhere else (i.e. function editor).

      • Yair Altman March 14, 2013 at 17:46

        @Ivan – I see. I don’t think it’s easy, but perhaps it could be done. The CW text colors are set using attributes that are set for specific sections (chars 12-34 use set #1, chars 35-75 use set #2 and so on). You can play with these attributes as I have done in my cprintf utility. Be warned, it’s not going to be easy…

    • Ivan Klyuzhin March 14, 2013 at 17:52 Reply

      @Yair – Thanks much, I’ll look into it!

  27. pump April 28, 2013 at 17:21 Reply

    unfortunately this doesn’t work in the command window which is run when Matlab is passed -nodesktop argument

    • Yair Altman April 28, 2013 at 23:13 Reply

      @pump – of course not. It only works when the output is sent to the Java Desktop. When you send it to the OS’s command prompt it cannot possibly work. Try using the TCPRINTF utility instead.

  28. George May 3, 2013 at 10:27 Reply

    Thank you, this was very useful. I added this to my startup file to make each instance of Matlab I open a new color.

    • Yair Altman May 4, 2013 at 10:25 Reply

      @George – interesting use-case indeed. Thanks for sharing.

  29. cariacou November 8, 2013 at 12:59 Reply

    Hi Yair.

    I was reading through this post and tried to find a few attributes of the command window that I could use to personalize my programm but couldn’t find them.

    do you know by chance how to get the size of the command window ?
    I would like to use the number of characters that can be displayed without having to slide left and right.

    thanks !

    • Yair Altman November 10, 2013 at 01:25 Reply

      @Cariacou – yes, here’s how:

      % Get the Command Window's text-area reference
      cmdWinDoc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance;
      listeners = cmdWinDoc.getDocumentListeners;
      jTextArea = listeners(4);  % this could be listeners(3) in some Matlabs - check your specific case!
       
      % Get the containing viewport's visible window width
      visibleWidth = jTextArea.getAccessibleParent.getVisibleRect.getWidth;
       
      % Divide by the character width (assume monospace font)
      font = jTextArea.getFont;
      charWidth = jTextArea.getFontMetrics(font).stringWidth('m');
      numChars = visibleWidth / charWidth;

      % Get the Command Window's text-area reference cmdWinDoc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance; listeners = cmdWinDoc.getDocumentListeners; jTextArea = listeners(4); % this could be listeners(3) in some Matlabs - check your specific case! % Get the containing viewport's visible window width visibleWidth = jTextArea.getAccessibleParent.getVisibleRect.getWidth; % Divide by the character width (assume monospace font) font = jTextArea.getFont; charWidth = jTextArea.getFontMetrics(font).stringWidth('m'); numChars = visibleWidth / charWidth;

    • Yair Altman January 14, 2014 at 16:36 Reply

      Here is another method that I just found:

      rows = builtin('_getcmdwinrows');
      cols = builtin('_getcmdwincols');

      rows = builtin('_getcmdwinrows'); cols = builtin('_getcmdwincols');

      These built-in functions are defined in %matlabroot%/bin/registry/libmwservices.xml

  30. lea May 13, 2014 at 01:09 Reply

    Hi Yair,

    Kudos for the great blog!
    I wonder if there’s a way to manipulate the already printed text in the command pane. Could be useful for ‘realtime’ text animation (progress indication).

    p.s. Beside the obvious solution to manipulate the line with control characters… I mean lines from previous prints.

    10x,
    Lea

    • Yair Altman May 13, 2014 at 13:28 Reply

      @Lea – you can do it by accessing the Command Window’s XCmdWndView component, which is basically just a Java Swing JTextArea with a few Matlab customizations. You can get started in this article describing my cprintf utility.

  31. ale December 4, 2015 at 04:53 Reply

    Unfortunately, this doesn’t work on matlab R2015a. I often have many matlab sessions open at the same time and I usually change the title using a free windows utility, but sometimes that is not enough. Changing the background color of different matlab sessions can save potential disasters!

    If I try any of the proposed commands, I get:

    set(jTextArea,'Background','yellow');
    Error using set
    The name 'Background' is not an accessible property for an
    instance of class 'com.mathworks.mde.cmdwin.CmdWinUndoManager'.

    set(jTextArea,'Background','yellow'); Error using set The name 'Background' is not an accessible property for an instance of class 'com.mathworks.mde.cmdwin.CmdWinUndoManager'.

    These are the properties of the object:

    get(jTextArea)
                             Class: [1x1 java.lang.Class]
                        InProgress: 1
                             Limit: 100
                  PresentationName: ''
              RedoPresentationName: 'Redo'
                       Significant: 0
        UndoOrRedoPresentationName: 'Undo'
              UndoPresentationName: 'Undo'

    get(jTextArea) Class: [1x1 java.lang.Class] InProgress: 1 Limit: 100 PresentationName: '' RedoPresentationName: 'Redo' Significant: 0 UndoOrRedoPresentationName: 'Undo' UndoPresentationName: 'Undo'

    and these are the methods:

    methods(jTextArea)
     
    Methods for class com.mathworks.mde.cmdwin.CmdWinUndoManager:
     
    addEdit                        insertUpdate                   
    canRedo                        isInProgress                   
    canUndo                        isSignificant                  
    canUndoOrRedo                  notify                         
    changedUpdate                  notifyAll                      
    die                            redo                           
    discardAllEdits                removeUpdate                   
    end                            replaceEdit                    
    equals                         setLimit                       
    getClass                       toString                       
    getLimit                       undo                           
    getPresentationName            undoOrRedo                     
    getRedoPresentationName        undoableEditHappened           
    getUndoOrRedoPresentationName  wait                           
    getUndoPresentationName        
    hashCode

    methods(jTextArea) Methods for class com.mathworks.mde.cmdwin.CmdWinUndoManager: addEdit insertUpdate canRedo isInProgress canUndo isSignificant canUndoOrRedo notify changedUpdate notifyAll die redo discardAllEdits removeUpdate end replaceEdit equals setLimit getClass toString getLimit undo getPresentationName undoOrRedo getRedoPresentationName undoableEditHappened getUndoOrRedoPresentationName wait getUndoPresentationName hashCode

    Is there any way to do the same on this matlab version?
    Thank you for your precious work.

    • Yair Altman February 4, 2016 at 22:57 Reply

      @Ale – First, did you really expect some undocumented functionality that I wrote about back in 2009 to continue working in 2015 ?! Be realistic!

      Secondly, it turns out that somewhere along the years the required JTextArea handle moved from being stored in listeners(3) to listeners(4) (read the comments above!) and then listeners(5).

      In short, you can’t expect undocumented features to remain exactly as-is, unchanged, for so many years. At the very least you need to invest a bit of effort to check around and see maybe only a small thing has changed (as in this case). And in any case, you need to spend the time to at least read other peoples’ comments to see whether they answer your question.

      Nothing personal 🙂

  32. Sunki Reddy Gunugu September 21, 2020 at 13:52 Reply

    hi
    1.i would like to know how the error in command window of matlab is captured and displayed in the GUI with the same color in CW
    2. Is their any way to replicate the exact CW stuff with same colors and font in the GUI.

    • Yair Altman September 23, 2020 at 11:26 Reply

      There is no direct way to replicate the CW in a GUI window, you’ll need to display the text in the GUI using your program logic.
      Here is one possible implementation that could assist you: http://undocumentedmatlab.com/articles/rich-contents-log-panel

Leave a Reply
HTML tags such as <b> or <i> are accepted.
Wrap code fragments inside <pre lang="matlab"> tags, like this:
<pre lang="matlab">
a = magic(3);
disp(sum(a))
</pre>
I reserve the right to edit/delete comments (read the site policies).
Not all comments will be answered. You can always email me (altmany at gmail) for private consulting.

Click here to cancel reply.

Useful links
  •  Email Yair Altman
  •  Subscribe to new posts (feed)
  •  Subscribe to new posts (reader)
  •  Subscribe to comments (feed)
 
Accelerating MATLAB Performance book
Recent Posts

Speeding-up builtin Matlab functions – part 3

Improving graphics interactivity

Interesting Matlab puzzle – analysis

Interesting Matlab puzzle

Undocumented plot marker types

Matlab toolstrip – part 9 (popup figures)

Matlab toolstrip – part 8 (galleries)

Matlab toolstrip – part 7 (selection controls)

Matlab toolstrip – part 6 (complex controls)

Matlab toolstrip – part 5 (icons)

Matlab toolstrip – part 4 (control customization)

Reverting axes controls in figure toolbar

Matlab toolstrip – part 3 (basic customization)

Matlab toolstrip – part 2 (ToolGroup App)

Matlab toolstrip – part 1

Categories
  • Desktop (45)
  • Figure window (59)
  • Guest bloggers (65)
  • GUI (165)
  • Handle graphics (84)
  • Hidden property (42)
  • Icons (15)
  • Java (174)
  • Listeners (22)
  • Memory (16)
  • Mex (13)
  • Presumed future risk (394)
    • High risk of breaking in future versions (100)
    • Low risk of breaking in future versions (160)
    • Medium risk of breaking in future versions (136)
  • Public presentation (6)
  • Semi-documented feature (10)
  • Semi-documented function (35)
  • Stock Matlab function (140)
  • Toolbox (10)
  • UI controls (52)
  • Uncategorized (13)
  • Undocumented feature (217)
  • Undocumented function (37)
Tags
AppDesigner (9) Callbacks (31) Compiler (10) Desktop (38) Donn Shull (10) Editor (8) Figure (19) FindJObj (27) GUI (141) GUIDE (8) Handle graphics (78) HG2 (34) Hidden property (51) HTML (26) Icons (9) Internal component (39) Java (178) JavaFrame (20) JIDE (19) JMI (8) Listener (17) Malcolm Lidierth (8) MCOS (11) Memory (13) Menubar (9) Mex (14) Optical illusion (11) Performance (78) Profiler (9) Pure Matlab (187) schema (7) schema.class (8) schema.prop (18) Semi-documented feature (6) Semi-documented function (33) Toolbar (14) Toolstrip (13) uicontrol (37) uifigure (8) UIInspect (12) uitable (6) uitools (20) Undocumented feature (187) Undocumented function (37) Undocumented property (20)
Recent Comments
Contact us
Captcha image for Custom Contact Forms plugin. You must type the numbers shown in the image
Undocumented Matlab © 2009 - Yair Altman
This website and Octahedron Ltd. are not affiliated with The MathWorks Inc.; MATLAB® is a registered trademark of The MathWorks Inc.
Scroll to top