
Undocumented Secrets of MATLAB
®
-Java Programming276
The beans package’s ColorPicker is an alternative component provided by MATLAB:
>> cp = com.mathworks.beans.editors.ColorPicker;
>> [jColorPicker,container]=javacomponent(cp,[1,1,400,200],gcf);
>> jColorPicker.getSelectedColor
ans=
java.awt.Color[r=255,g=86,b=158]
MATLAB’s ColorPicker
The selection color can be specied using the ColorPicker’s setSelectedColor() method:
cp.setSelectedColor(0,0,255); % = blue
cp.repaint; % necessary if the component is already displayed
Similarly, the original color can be specied using the setInitialColor() method:
cp.setInitialColor(255,0,0); % = red
cp.repaint;