Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: uisetcolor + activeX ->figure without focus, if compiled
Date: Wed, 4 Nov 2009 13:29:03 +0000 (UTC)
Organization: TACT Computer Systems Ltd
Lines: 23
Message-ID: <hcrviv$9uo$1@fred.mathworks.com>
References: <gpdqsp$29p$1@fred.mathworks.com> <gtphhd$ggg$1@fred.mathworks.com> <h61v4h$hgj$1@fred.mathworks.com> <h6gbut$mco$1@fred.mathworks.com> <h6gck2$59g$1@fred.mathworks.com> <h6h023$lj$1@fred.mathworks.com> <h6h4co$leh$1@fred.mathworks.com> <hcritt$113$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257341343 10200 172.30.248.37 (4 Nov 2009 13:29:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Nov 2009 13:29:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 642467
Xref: news.mathworks.com comp.soft-sys.matlab:582355


> > Not sure if it will make a difference, but you could try using a JColorChooser instead of uisetcolor. See the demo file in my file "rgb2name" on the file exchange for an example of how it works. 
> 
> Matt,
> 
> Thanks for this excellent suggestion. It looks like it solves a similar problem I am having with uisetcolor freezing the main figure in a compiled program (compiled using compiler V79 that is shipped with R2008b). Do you know how to get the JColorChooser to initialise with a colour other than white? (i.e. I want it to start with the colour that is already assigned to a uicontrol).
> 
> Thanks in advance
> Thomas


You can pass a Java Color object to JColorChooser upon construction. For example:

hColor = get(hControl,'BackgroundColor');
cColor = mat2cell(hcolor,1,[1,1,1]);  % convert to cell array
jColor = java.awt.Color(cColor{:});  % convert to Java Color object
jObject = JColorChooser(jColor);  % prepare the JColorChooser etc.

More info:
http://java.sun.com/javase/6/docs/api/javax/swing/JColorChooser.html
http://java.sun.com/docs/books/tutorial/uiswing/components/colorchooser.html

Yair Altman
http://undocumentedMatlab.com