-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
date/time not getting updated in WebDateField #579
Comments
Thanks for the information! |
date = new Date(earthClock.getInstant().toEpochMilli());
dateField.setDate(date) This most certainly works for me, can you provide a small example where it doesn't for you?
date.setTime(earthClock.getInstant().toEpochMilli());
// dateField.setDate(date); This is actually a bad idea, I personally recommend to never ever reuse |
I'm on v1.2.10.
Ok I surely hope there's a way to listen in the changes in the timestamp. One big problem I found in my app is that if I click on the calendar button on the right of the textfield, it won't open the calendar. OR should I say as soon as it's being opened, since a new Date object is being provided to increment/update the time, the calendar will collapse. So updating the Date object frequently will totally defeat the purpose of having the WeDateField in that users can see the visual calendar :( Is there a workaround to keep the calendar object in the open state, while the Date is being updated ? EDIT: |
- WebDateField.java - Now creates a copy of provided `Date` and returns a copy of selected day when requested to avoid it's modification
Not sure what you meant by that. If you set a new Unfortunately nothing can be done about the first case because /**
* Sets this <code>Date</code> object to represent a point in time that is
* <code>time</code> milliseconds after January 1, 1970 00:00:00 GMT.
*
* @param time the number of milliseconds.
*/
public void setTime(long time) {
fastTime = time;
cdate = null;
} For the second case I've added a small fix that will simply use a new |
Could you provide a small code example of this use-case? |
- WebDateFieldUI.java - Calendar popup will not be closed anymore when date or date format is changed while it's open
Date field popup will not close anymore when date or date format is changed while it's open. Calendar will properly update to newly provided date as well. Here is the example I used for testing this problem: public final class DateCalendarPopupTest
{
public static void main ( final String[] args )
{
SwingTest.run ( new Runnable ()
{
@Override
public void run ()
{
final WebDateField dateField = new WebDateField ( new Date () );
TestFrame.show ( dateField );
WebTimer.repeat ( 1000, new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
dateField.setDate ( new Date ( dateField.getDate ().getTime () + 24 * 60 * 60 * 1000 ) );
}
} );
}
} );
}
} |
I just found out an issue with WebDataField.
See also #257
I can set the date/time to a value INITIALLY as follows :
However, in my app's game loop, I need to constantly update the date/timestamp.
So if I do the following once per frame, it won't work :
OR:
The only way it works is keeping create a brand new Date each time as follows:
dateField.setDate(new Date(earthClock.getInstant().toEpochMilli()));
The text was updated successfully, but these errors were encountered: