How to add components to the existing GUI created by the manual?

I just created a GUI using the tutorial in MATLAB for a small project that I am working on. I have, among other things, two text fields for dates and dates. Now I would like to get rid of them and use the Java date picker. Of course, this is not possible with a guide, so I need to add them manually. I managed to get them to appear by putting this code in my Open_Fcn,

uicomponent(handles, 'style','com.jidesoft.combobox.DateChooserPanel','tag','til2'); 

using UICOMPONENT .

But even if it appears, I cannot access the date picker attributes, for example

 get(handles.til2) 

returns

 ??? Reference to non-existent field 'til2'. 

How can i fix this?

+4
source share
1 answer

Unless you edit the saved GUI graphic, the basic structure of handles will not include your new component by default.

One way to access your component is to save the handle through guidata by adding the following to your open function:

 handles.til2 = uicomponent(handles, 'style','com.jidesoft.combobox.DateChooserPanel','tag','til2'); guidata(hObject,handles) 

Functions that need to access the descriptor require a string

 handles = guidata(hObject) 

to return the full descriptor structure that includes the submitted til2

+3
source

Source: https://habr.com/ru/post/1337960/


All Articles