How can I put a javacomponent in the app designer?
Show older comments
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 hgjavacomponent
Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in
App Designer.
Error in javacomponentdoc_helper
Error in javacomponentdoc_helper
Error 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 hgjavacomponent
Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support
in App Designer.
Error in javacomponentdoc_helper
Error in javacomponentdoc_helper
Error 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?
Accepted Answer
More Answers (1)
Ivan Qin
on 8 May 2019
0 votes
I have the same question. I put the call to javacomponent in the app Construct section and it did not work either.
Anybody has idea?
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!