From: Matthew C on
I have a few list boxes in a GUI. It seems the default selection color is blue and when the list box is de-selected (clicking somewhere else), the selected text becomes gray.

Is there a way to have both of them remain blue without using "undocumented" matlab properties. Thanks in advance.
From: Yair Altman on
"Matthew C" <matthew_lane9(a)hotmail.com> wrote in message <hod4v5$oh5$1(a)fred.mathworks.com>...
> I have a few list boxes in a GUI. It seems the default selection color is blue and when the list box is de-selected (clicking somewhere else), the selected text becomes gray.
>
> Is there a way to have both of them remain blue without using "undocumented" matlab properties. Thanks in advance.


This cannot be done using documented features. Here's the undocumented way to do it:

1. Download my FindJObj utility from the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/14317-findjobj-find-java-handles-of-matlab-graphic-objects

2. Place the following in your Matlab code, when the focus is on the listbox:
jListbox = findjobj(hListbox);
jListbox=jListbox.getViewport.getComponent(0);
jListbox.setSelectionAppearanceReflectsFocus(0);

Note that action #2 "freezes" the current selection color, so if your listbox is not in focus when you run it, the gray selection color will remain even when the listbox is back in focus...

Yair Altman
http://UndocumentedMatlab.com