The "One Laptop Per Child" project has a great device ready to ship, but there's no Java on there. Let's think about working together to put Java on OLPC!
Eclipse 3.3 M3 brings with it a new build of SWT, and with that a new widget: the
org.eclipse.swt.widgets.DateTime
control. Something missing from native SWT support until now has been a date/calendar picker; that is no longer the case. The DateTime class is a simple, natively supported widget for just that.
There are three formats readily available in the DateTime control: Date entry, Time entry, and a Calendar. Creating the three different formats is quite simple; here is how you create each:
DateTime calendar = new DateTime(parent, SWT.CALENDAR);
DateTime dateEntry = new DateTime(parent, SWT.DATE);
DateTime timeEntry = new DateTime(parent, SWT.TIME);
Date and time formats look fairly similar - the only real difference is the entry format that they support:
As for calendar, this is one of those widgets like a file chooser that can extol the virtues of SWT's native peer support. GTK has a native calendar date-picker that supports several layout formats; here is a comparison of the Gnome clock control (which uses the GTK calendar control) with my SWT calendar component (native GTK on the left, SWT on the right):
The comparison is of course fairly silly since SWT is not emulating the platform, but using it. Getting the user-input off of the date-time wiget is easy too. This widget has simple methods for retrieving the various input values using the
java.util.Calendar
API - in fact, DateTime uses
Calendar.getInstance()
internally to ensure it is locale-friendly. Here is some example code:
DateTime dt = new DateTime(parent, SWT.DATE); // or SWT.TIME if desired
int day = dt.getDay(); // Calendar.DAY_OF_MONTH
int hour = dt.getHours(); // Calendar.HOUR_OF_DAY
int min = dt.getMinutes(); // Calendar.MINUTE
int month = dt.getMonth(); // Calendar.MONTH
int second = dt.getSeconds(); // Calendar.SECOND
int year = dt.getYear(); // Calendar.YEAR
These ints relate directly to the constants on the
java.util.Calendar
class, such as
Calendar.JANUARY
for
dt.getMonth()
.
That's about it for now - keep in mind this is a young widget, and until Eclipse 3.3 releases (Q2 2007), it's still in a milestone status, and the API is not yet solid. Incidentally, while there is no promise, it looks like they have considered making it public API for the user to set the date format that is offered on the date/time API via a
setFormat(String)
method.
Since this is an official SWT widget, so you should share your ideas on the newsgroups: http://www.eclipse.org/newsgroups/ ... and you should open any feature requests (once you have used it and have formulated your thoughts) into Eclipse bugzilla (Eclipsezilla): https://bugs.eclipse.org/bugs/
SWT: The Newly Available DateTime Control
At 12:33 AM on Nov 6, 2006, R.J. Lorimer
wrote:
Eclipse 3.3 M3 brings with it a new build of SWT, and with that a new widget: the
org.eclipse.swt.widgets.DateTimecontrol. Something missing from native SWT support until now has been a date/calendar picker; that is no longer the case. The DateTime class is a simple, natively supported widget for just that.There are three formats readily available in the DateTime control: Date entry, Time entry, and a Calendar. Creating the three different formats is quite simple; here is how you create each:
Date and time formats look fairly similar - the only real difference is the entry format that they support:
As for calendar, this is one of those widgets like a file chooser that can extol the virtues of SWT's native peer support. GTK has a native calendar date-picker that supports several layout formats; here is a comparison of the Gnome clock control (which uses the GTK calendar control) with my SWT calendar component (native GTK on the left, SWT on the right):
The comparison is of course fairly silly since SWT is not emulating the platform, but using it. Getting the user-input off of the date-time wiget is easy too. This widget has simple methods for retrieving the various input values using the
java.util.CalendarAPI - in fact, DateTime usesCalendar.getInstance()internally to ensure it is locale-friendly. Here is some example code:These ints relate directly to the constants on the
java.util.Calendarclass, such asCalendar.JANUARYfordt.getMonth().That's about it for now - keep in mind this is a young widget, and until Eclipse 3.3 releases (Q2 2007), it's still in a milestone status, and the API is not yet solid. Incidentally, while there is no promise, it looks like they have considered making it public API for the user to set the date format that is offered on the date/time API via a
setFormat(String)method.7 replies so far (
Post your own)
Re: SWT: The Newly Available DateTime Control
Great! I'm currently using swtcalendar but I'm not really satisfied with it.Could you tell me were I could post some suggestions for this new widgets?
Re: SWT: The Newly Available DateTime Control
Since this is an official SWT widget, so you should share your ideas on the newsgroups: http://www.eclipse.org/newsgroups/... and you should open any feature requests (once you have used it and have formulated your thoughts) into Eclipse bugzilla (Eclipsezilla): https://bugs.eclipse.org/bugs/
Thanks!
Re: SWT: The Newly Available DateTime Control
coolRe: SWT: The Newly Available DateTime Control
It's a very good news. Now I'm using CDatePickerCombo widget from Aspencloud and I will recommend it (http://www.aspencloud.org/screenshots.php). It's very very nice.Regards, jtonic.
Re: SWT: The Newly Available DateTime Control
This is great!Is there any news of when/whether a generalized FormattedText widget will make it into the official SWT? See Eclipse Bugzilla Bug 85935.
Thanks
Re: SWT: The Newly Available DateTime Control
Where have the images gone?http://www.eclipsezone.com/team/rj/eclipse_date_time/1.jpg
Re: SWT: The Newly Available DateTime Control
Any ideas why double click doesn't seem to work (at least on windows)...calendar.addMouseListener(new MouseListener() { public void mouseUp(MouseEvent e) { // this works fine! } public void mouseDown(MouseEvent e) { } public void mouseDoubleClick(MouseEvent e) { System.err.println("This never happens!"); } });