Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
jumping directly to uisetcolor "more color..." tab

Subject: jumping directly to uisetcolor "more color..." tab

From: Hiep

Date: 29 Nov, 2012 23:01:11

Message: 1 of 4

Hi,

I am exploring uisetcolor. How can we set control such that when I press color selection button (such as the example below) the color picker opens automatically Swatches (or HSB, or RGB) tab under 'More Color...'. I dont want to use the default swatches which has limited colors, because then the user has to switch to More Color... every time, which make them annoyed/bored/lose patience with my experiment.

Thanks all.

function test
f=figure;
 uicontrol('Parent',f,'Style', 'pushbutton',...
    'Position', [0 0 130 30],'String','Color',...
    'CallBack',@color_Callback);
actxcontrol('OWC.Spreadsheet.9', [150 150 300 300],f);
return

function color_Callback(hObject, eventdata, handles)
  c1=get(gcf,'Color');
  c = uisetcolor(c1, 'Entity color');
  uicontrol(hObject);
  disp('HALLO') ;
  if sum(c1==c)<3
    set(gcf,'Color',c);
  end
return

Subject: jumping directly to uisetcolor "more color..." tab

From: Yair Altman

Date: 30 Nov, 2012 07:44:15

Message: 2 of 4

"Hiep " <pegagus216@yahoo.com> wrote in message <k98pfn$arv$1@newscl01ah.mathworks.com>...
> Hi,
>
> I am exploring uisetcolor. How can we set control such that when I press color selection button (such as the example below) the color picker opens automatically Swatches (or HSB, or RGB) tab under 'More Color...'. I dont want to use the default swatches which has limited colors, because then the user has to switch to More Color... every time, which make them annoyed/bored/lose patience with my experiment.


Don't use uisetcolor. Instead, create a simple dialog window with one of the built-in Java color components: http://UndocumentedMatlab.com/blog/color-selection-components/

Yair Altman
http://UndocumentedMatlab.com
Read my Matlab-Java programming book
 

Subject: jumping directly to uisetcolor "more color..." tab

From: Hiep

Date: 30 Nov, 2012 21:58:07

Message: 3 of 4

Hello Yair,

Thanks for the quick response. Your website was actually the first I looked at, and I found it really cool. Yet I am not very familiar with incorporating Java component in Matlab, so I fell back to uigetcolor. Now that you're here, can you enlighten me:
1. where is the Ok to confirm selection in every example of yours. How to get the return value. I managed to get the chosen color from

cc = javax.swing.JColorChooser;
>> [jColorChooser,container] = javacomponent(cc,[1,1,450,325],gcf);

by jColorChooser.getColor, but for

cp = com.mathworks.mlwidgets.graphics.ColorPicker(options,icon,'');
[jColorPicker,hContainer] = javacomponent(cp,[10,220,30,20],gcf);

jColorPicker.getColor is not valid.

2. In my design I'd like to have a square, then a color selection button next to it like
options = 0; icon = 0;
cp = com.mathworks.mlwidgets.graphics.ColorPicker(options,icon,'');
that will open the swatches of
cc = javax.swing.JColorChooser;

to pick the color for the square. I tried cc = javax.swing.JColorChooser(options, icon. '');
but failed, apparently because I dont know the function signature.

Where can I find more info on the prototype, methods, properties of components like ColorPicker, jColorPicker, JColorChooser, etc., to modify as will?
I do hope the anwer wont be "purchase my report/book".
many thanks.

"Yair Altman" wrote in message <k99o4f$4gc$1@newscl01ah.mathworks.com>...
> "Hiep " <pegagus216@yahoo.com> wrote in message <k98pfn$arv$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > I am exploring uisetcolor. How can we set control such that when I press color selection button (such as the example below) the color picker opens automatically Swatches (or HSB, or RGB) tab under 'More Color...'. I dont want to use the default swatches which has limited colors, because then the user has to switch to More Color... every time, which make them annoyed/bored/lose patience with my experiment.
>
>
> Don't use uisetcolor. Instead, create a simple dialog window with one of the built-in Java color components: http://UndocumentedMatlab.com/blog/color-selection-components/
>
> Yair Altman
> http://UndocumentedMatlab.com
> Read my Matlab-Java programming book
>

Subject: jumping directly to uisetcolor "more color..." tab

From: Hiep

Date: 2 Dec, 2012 21:23:08

Message: 4 of 4

Hello Yair,

Thanks for the quick response. Your website was actually the first I looked at, and I found it really cool. Yet I am not very familiar with incorporating Java component in Matlab, so I fell back to uigetcolor. Now that you're here, can you enlighten me:
1. where is the Ok to confirm selection in every example of yours. How to get the return value. I managed to get the chosen color from

cc = javax.swing.JColorChooser;
>> [jColorChooser,container] = javacomponent(cc,[1,1,450,325],gcf);

by jColorChooser.getColor, but for

cp = com.mathworks.mlwidgets.graphics.ColorPicker(options,icon,'');
[jColorPicker,hContainer] = javacomponent(cp,[10,220,30,20],gcf);

jColorPicker.getColor is not valid.

2. In my design I'd like to have a square, then a color selection button next to it like
options = 0; icon = 0;
cp = com.mathworks.mlwidgets.graphics.ColorPicker(options,icon,'');
that will open the swatches of
cc = javax.swing.JColorChooser;

to pick the color for the square. I tried cc = javax.swing.JColorChooser(options, icon. '');
but failed, apparently because I dont know the function signature.

Where can I find more info on the prototype, methods, properties of components like ColorPicker, jColorPicker, JColorChooser, etc., to modify as will?
I do hope the anwer wont be "purchase my report/book".
many thanks.

"Yair Altman" wrote in message <k99o4f$4gc$1@newscl01ah.mathworks.com>...
> "Hiep " <pegagus216@yahoo.com> wrote in message <k98pfn$arv$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > I am exploring uisetcolor. How can we set control such that when I press color selection button (such as the example below) the color picker opens automatically Swatches (or HSB, or RGB) tab under 'More Color...'. I dont want to use the default swatches which has limited colors, because then the user has to switch to More Color... every time, which make them annoyed/bored/lose patience with my experiment.
>
>
> Don't use uisetcolor. Instead, create a simple dialog window with one of the built-in Java color components: http://UndocumentedMatlab.com/blog/color-selection-components/
>
> Yair Altman
> http://UndocumentedMatlab.com
> Read my Matlab-Java programming book
>

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us