Salut tout le monde,
Le code suivant permet de créer une jListe comportant des checkBoxes. Quand je lance la simulation la jListe et toutes les informations liées à la jListe sont indiquées sur le workspace.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 % First create the data model jList = java.util.ArrayList; % any java.util.List will be ok jList.add(0,'First'); jList.add(1,'Second'); jList.add(2,'Third'); jList.add(3,'Forth'); jList.add(4,'Fifth'); jList.add(5,'Sixth'); jList.add(6,'and last'); % Next prepare a CheckBoxList component within a scroll-pane jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(jList); jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList); % Now place this scroll-pane within a Matlab container (figure or panel) [jhScroll,hContainer] = javacomponent(jScrollPane,[10,10,100,100],gcf); % Update some items' state programmatically % jCBModel = jCBList.getCheckModel; % jCBModel.checkAll; % jCBModel.uncheckIndex(1); % jCBModel.uncheckIndex(3); % % Respond to checkbox update events % jhCBModel = handle(jCBModel, 'CallbackProperties'); % set(jhCBModel, 'ValueChangedCallback', @myMatlabCallbackFcn);
Je veux afficher la jListe en cliquant sur un pushbutton, donc je rajoute le code ci-dessus à la fonction d'un pushbutton comme suite:
La liste comportant les checkboxes s'affiche mais je récupère rien sur le workspace.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 function pushbutton1_Callback(hObject, eventdata, handles) % First create the data model jList = java.util.ArrayList; % any java.util.List will be ok jList.add(0,'First'); jList.add(1,'Second'); jList.add(2,'Third'); jList.add(3,'Forth'); jList.add(4,'Fifth'); jList.add(5,'Sixth'); jList.add(6,'and last'); assignin('base', 'jList', jlist); % Next prepare a CheckBoxList component within a scroll-pane jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(jList); jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList);
Comment pourrai-je récupérer la liste sur le workspace?
Merci
Partager