Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Changing preferences from command line
Date: Thu, 14 Aug 2008 02:03:02 +0000 (UTC)
Organization: IDB Bank
Lines: 44
Message-ID: <g803om$4e2$1@fred.mathworks.com>
References: <f9vhri$orl$1@fred.mathworks.com> <fa415r$kk8$1@fred.mathworks.com> <fa48lm$834$1@fred.mathworks.com> <fa498v$hr8$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1218679382 4546 172.30.248.38 (14 Aug 2008 02:03:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 14 Aug 2008 02:03:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1319018
Xref: news.mathworks.com comp.soft-sys.matlab:485384



Yair 
Many, many thanks for this clear & concise explanation. It 
was exactly what I was looking for. Im running two instances
of Matlab and using it to set a different background color
in each. Using these java calls on the preferences has got
me tantalisingly close to a solution ... maybe I could ask
your expert advice to get to completion?

This is the code im using:
% dont use system color
com.mathworks.services.Prefs.setBooleanPref('ColorsUseSystem',0);
% use specified color
com.mathworks.services.Prefs.setColorPref('ColorsBackground',<whatever>)

where <whatever> is a java.awt.Color object returned by
com.mathworks.services.Prefs.getColorPref('ColorsBackground')

My problem now is that the new color (or preference) does
not take effect on the desktop immediately. Instead, it
comes into effect either after a restart of Matlab or if I
open the Preferences dialog manually and then push 'Apply'.

So a quick 'n dirty solution is to use:

preferences('Colors') this opens the dialog box and then
requires the user to push 'ok' or 'Apply'. It gets the job
done, but not as elegantly as I would like.

I would like to either 
1) Call the code behind the Apply button in the Preferences
dialog; or
2) Force matlab to pick up the new preferences as it would
at startup; or
3) 'refresh' the desktop

If anyone can shed light on any of these approaches I would
be most grateful. Im using R2007b,
many thanks
Ben

ps: For anyone else that's playing with this: I dont advise
trying to edit the matlab.prf via matlab(!). I created a
situation that made Matlab unworkable. I did find that
deleting the matlab.prf completely (in frustration) solved it.