Comments on: Date selection components https://undocumentedmatlab.com/blog_old/date-selection-components Charting Matlab's unsupported hidden underbelly Thu, 07 Sep 2023 16:43:44 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Andrés Aguilarhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-512399 Fri, 21 Apr 2023 18:07:53 +0000 https://undocumentedmatlab.com/?p=1684#comment-512399 Hello, has anyone tried to change the language of the DateComboBox? For example

English -> French
——————-
January -> Janvier
April -> Avril

English -> Italian
——————-
Today -> Oggi
None -> Nessuna

Thanks in advance!

]]>
By: Alexhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-430480 Thu, 21 Jun 2018 16:06:05 +0000 https://undocumentedmatlab.com/?p=1684#comment-430480 Thanks so much for your help Yair, code worked perfectly, you’re a life saver.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-430467 Thu, 21 Jun 2018 13:30:30 +0000 https://undocumentedmatlab.com/?p=1684#comment-430467 @Alex – You can disable certain dates and date-ranges in the calendar as follows:

jDateChooser = javaObjectEDT(com.jidesoft.combobox.DateComboBox);
jDateModel = jDateChooser.getDateModel;
calendar = java.util.Calendar.getInstance;
calendar.setTime(java.util.Date(datestr(startDateNum)));
jDateModel.setMinDate(calendar);  % and similarly for MaxDate

Similarly, you can use jDateModel.addInvalidDate(calendar) to add specific invalid dates within the relevant min/max dates.

You can set the date chooser to have a different initial (default) date value, but the current date is always marked on the calendar and AFAIK this cannot be avoided.

If you’d like any additional assistance with your Matlab project, please contact me by email for a consulting offer.

]]>
By: Alexhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-430357 Wed, 20 Jun 2018 19:30:31 +0000 https://undocumentedmatlab.com/?p=1684#comment-430357 Hi Yair,

I noticed that for the DateComboBox, the current date value was outlined in red (by default) and remained that way even when the selection was changed. Is there any way to move that red outline to another initialized date? Also, I wanted to set a selectable date range, was there any way to do that easily (say by greying out non-valid dates)? Thanks in advance for the help!

]]>
By: Mohammadhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-427150 Fri, 25 May 2018 15:09:58 +0000 https://undocumentedmatlab.com/?p=1684#comment-427150 Dear Yair,

Many thanks for your help….

Kind Regards,
Mohammad

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-424867 Sun, 06 May 2018 08:59:12 +0000 https://undocumentedmatlab.com/?p=1684#comment-424867 Mohammad – read the post carefully: I explained near the bottom how you can get the handle and set callbacks to get the user-selected date.

]]>
By: Mohammadhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-424690 Fri, 04 May 2018 10:50:47 +0000 https://undocumentedmatlab.com/?p=1684#comment-424690 Dear Yair

I have inserted Date selection components into my MATLAB GUI but I do know how I can make a handle for the Date selection components in order to update the date which is selected by user.

Many thanks in advance….

Kind Regards,

Mohammad

]]>
By: Mikhailhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-392353 Thu, 03 Nov 2016 13:44:34 +0000 https://undocumentedmatlab.com/?p=1684#comment-392353 Yes, that works! Thank you!

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-392237 Wed, 02 Nov 2016 13:09:28 +0000 https://undocumentedmatlab.com/?p=1684#comment-392237 @Mikail – try to add drawnow; pause(0.1) after you call javacomponent.
See https://undocumentedmatlab.com/blog/matlab-and-the-event-dispatch-thread-edt

]]>
By: Mikhailhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-392226 Wed, 02 Nov 2016 08:29:18 +0000 https://undocumentedmatlab.com/?p=1684#comment-392226 Hi, Yair Altman!
I use this helpful functionality but got interesting problem:

Create calendar this way:

% --- Executes just before AddEditDoc is made visible.
function AddEditDoc_OpeningFcn(hObject, eventdata, handles, varargin)
   % code code code
   handles.jPanel = com.jidesoft.combobox.DateChooserPanel;
   [hPanel,hContainer] = javacomponent(handles.jPanel,[500,130,200,200],gcf);
   handles.hPanel = hPanel;
   handles.output = hObject;
   set(handles.hPanel, 'MousePressedCallback', ...
       @(src, evnt)CellSelectionCallback(src, evnt, handles));
   set(handles.hPanel, 'KeyPressedCallback', ...
       @(src, evnt)CellSelectionCallback(src, evnt, handles));
   guidata(hObject, handles);

And Callback function:

function CellSelectionCallback(hObject, evnt, handles)
   hModel = handle(hObject.getSelectionModel, 'CallbackProperties');
   selectedDate = hModel.getSelectedDate();
   dayNumber = get(selectedDate,'Date');
   handles.edit_text.String = num2str(dayNumber); 
   guidata(handles.figure1, handles);

The problem: if I use Debug mode it works correct (put date day into this edit_text Object) but in normal mode it stays empty.
I thought a lot about some local variables deleted after exiting from function but still can’t figure out it.

Thank you

]]>
By: Heikohttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-369562 Wed, 10 Feb 2016 14:51:47 +0000 https://undocumentedmatlab.com/?p=1684#comment-369562 … found the solution: SetDate with Java date Format as Input java.util.Date()

]]>
By: Heikohttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-369561 Wed, 10 Feb 2016 14:35:42 +0000 https://undocumentedmatlab.com/?p=1684#comment-369561 Hi,

how to set the default date that Shows up when inititalizing the DateSpinnerComboBox?

Thanks,
Heiko

]]>
By: Efraïm Salarihttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-368392 Tue, 26 Jan 2016 09:35:58 +0000 https://undocumentedmatlab.com/?p=1684#comment-368392 Works perfect! Thanks for the help.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-367271 Tue, 12 Jan 2016 19:13:18 +0000 https://undocumentedmatlab.com/?p=1684#comment-367271 @Efraim – try to enlarge the component so that it has more space to display the 2-digit numbers.

]]>
By: Efraim Salarihttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-367270 Tue, 12 Jan 2016 18:53:56 +0000 https://undocumentedmatlab.com/?p=1684#comment-367270 Hi,
I only see day 1-9 of the month, all the other days are indicated with three dots (like this …). I work on linux matlab 2015a.

On windows, matlab 2014b it works properly!
Any suggestions?
Thanks,

]]>
By: amirhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-367238 Tue, 12 Jan 2016 04:02:02 +0000 https://undocumentedmatlab.com/?p=1684#comment-367238 is there menu for other kind of calenders such as month date (in arabic language) …
or sun date(in nfarsi language)… thanks alot

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-361831 Tue, 17 Nov 2015 18:00:58 +0000 https://undocumentedmatlab.com/?p=1684#comment-361831 You can set the java component’s Matlab container’s Units property to ‘normalized’ in order to automatically resize when the figure resizes:

% Display a DateChooserPanel
com.mathworks.mwswing.MJUtilities.initJIDE;
jPanel = com.jidesoft.combobox.DateChooserPanel;
[hPanel,hContainer] = javacomponent(jPanel,[10,10,200,200],gcf)
set(hContainer,'Units','norm')
]]>
By: Piyushhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-361828 Tue, 17 Nov 2015 17:38:29 +0000 https://undocumentedmatlab.com/?p=1684#comment-361828 I am using this Calendar. I was wondering does this have the functionality to resize itself if you change the screen. It would be great if you help me in this process.

]]>
By: David Mhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-343249 Sun, 04 Jan 2015 22:29:46 +0000 https://undocumentedmatlab.com/?p=1684#comment-343249 Hi Yair,

In my application, I have coupled the appearance of a DateChooserPanel with the selection of a pushbutton/calender icon. Here is my issue: the pushbutton is located in the middle of a number of edit/text boxes. As such, when the DateChooserPanel is made visible, it appears on-top of or behind the other objects around it, and stays that way even after I ‘close it’ (i.e. set visible to false). The only way I could figure to make a seamless appearance/disappearance of the DateChooserPanel involves creating and then deleting the java component handle ‘hPanel’ every time the pushbutton is selected. This works, but I was wondering if there was a better way? I have read in normal Java script, I would need to create a JLayeredPane or make use of GlassPane.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/date-selection-components#comment-339982 Thu, 04 Dec 2014 21:33:50 +0000 https://undocumentedmatlab.com/?p=1684#comment-339982 @Emma – you can display a time-selector in the date panel using the following code snippet:

jPanel.setTimeDisplayed(true)

There are also the related TimeFormat (default=”) and TimeZone properties that you can set.

If you need to interact with the time-related aspects of the panel, then you will need to investigate this yourself or hire me for a short consulting gig, since it’s beyond the scope of a simple blog comment.

]]>