139Rich GUI Using Java Swing
% (rather than use a MATLAB listbox uicontrol, directly use JList)
%hListbox = uicontrol('style','listbox', 'units','norm', ...
% 'position',[.05,.05,.3,.6], 'string',plotNames);
%jListbox = findjobj(hListbox,'nomenu');
%jListbox = jListbox.getViewport.getView; % in a scrollpane
jListbox = javax.swing.JList(plotNames);
[hjList,hcList] = javacomponent(jListbox,[10,10,100,200],hFig);
set(hcList,'units','norm','position',[.05,.05,.3,.6]);
% Add some plot axes
hAx1 = axes('position',[.5,.1,.45,.35]);
hAx2 = axes('position',[.5,.55,.45,.35]);
% Enable dragging from the listbox
jListbox.setDragEnabled(true);
% Enable drop on the figure axes
dnd = handle(java.awt.dnd.DropTarget(),'CallbackProperties');
jFrame = get(handle(hFig),'JavaFrame'); ...