In app designer, I tried to put checkbox created by 'com.jidesoft.swing.CheckBoxList'. but I can not settle it on app.UIFigure.
The code is
classdef test < matlab.apps.AppBase % Properties that correspond to app components
properties (Access = public) UIFigure matlab.ui.Figure end methods (Access = private) % Code that executes after component creation
function startupFcn(app) items = {'1','2','3','4','5','6','7','8','9'}; jCBList = com.jidesoft.swing.CheckBoxList; jCBList.setModel(javax.swing.DefaultListModel); jCBList.setSelectionMode(0); jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList); javacomponent(jScrollPane, [50,200,100,100], app.UIFigure); for i=1:size(items,2) jCBList.getModel.addElement(items{1,i}); end end end % App initialization and construction
methods (Access = private) % Create UIFigure and components
function createComponents(app) % Create UIFigure
app.UIFigure = uifigure; app.UIFigure.Position = [100 100 640 480]; app.UIFigure.Name = 'UI Figure'; end end methods (Access = public) % Construct app
function app = test % Create and configure components
createComponents(app) % Register the app with App Designer
registerApp(app, app.UIFigure) % Execute the startup function
runStartupFcn(app, @startupFcn) if nargout == 0 clear app end end % Code that executes before app deletion
function delete(app) % Delete UIFigure when app is deleted
delete(app.UIFigure) end end end
The Panel is
Error is like this
Error using hgjavacomponentFunctionality not supported with figures created with the uifigure function. For more information, see Graphics Support inApp Designer.Error in javacomponentdoc_helperError in javacomponentdoc_helperError in javacomponent (line 95)[hcomponent, hcontainer] = javacomponentdoc_helper(varargin{:});Error in test/startupFcn (line 19) javacomponent(jScrollPane, [50,200,100,100], fig);Error in test (line 52) runStartupFcn(app, @startupFcn)Error using hgjavacomponentFunctionality not supported with figures created with the uifigure function. For more information, see Graphics Supportin App Designer.Error in javacomponentdoc_helperError in javacomponentdoc_helperError in javacomponent (line 95)[hcomponent, hcontainer] = javacomponentdoc_helper(varargin{:});Error in test/startupFcn (line 19) javacomponent(jScrollPane, [50,200,100,100], app.UIFigure);Error in test (line 52) runStartupFcn(app, @startupFcn)
Is there a way to apply javacomponent into app designer?
Best Answer