Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

Java, the OLPC, and community responsibility

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!
Replies: 7 - Pages: 1  
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

SWT: The Newly Available DateTime Control

At 12:33 AM on Nov 6, 2006, R.J. Lorimer Javalobby Editors wrote:

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.

  Click to reply to this thread Reply
1. At 12:11 PM on Nov 6, 2006, Frederic Conrotte Blooming Javalobby Member wrote:

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?
  Click to reply to this thread Reply
2. At 12:27 PM on Nov 6, 2006, R.J. Lorimer Javalobby Editors wrote:

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!
Best, R.J. Lorimer
  Click to reply to this thread Reply
3. At 3:46 AM on Nov 7, 2006, Diego Guidi Blooming Javalobby Member wrote:

Re: SWT: The Newly Available DateTime Control

cool :)
  Click to reply to this thread Reply
4. At 3:36 AM on Nov 9, 2006, Pazargic Antonel Ernest Blooming Javalobby Member wrote:

Re: 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.
  Click to reply to this thread Reply
5. At 12:40 PM on Dec 1, 2006, Bill Blalock Occasional Javalobby Visitor wrote:

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
  Click to reply to this thread Reply
6. At 11:50 AM on Jan 14, 2008, Toby Weston Blooming Javalobby Member wrote:

Re: SWT: The Newly Available DateTime Control

Where have the images gone?

http://www.eclipsezone.com/team/rj/eclipse_date_time/1.jpg
  Click to reply to this thread Reply
7. At 9:58 AM on Apr 29, 2008, Toby Weston Blooming Javalobby Member wrote:

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!");
			}
		});

thread.rss_message