File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Does SWT provide a Calendar Widget? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Does SWT provide a Calendar Widget?" Watch "Does SWT provide a Calendar Widget?" New topic

Does SWT provide a Calendar Widget?

Sunil Aggarwal

Joined: Aug 26, 2004
Posts: 14
Hi All,

I require a Calendar widget, which I assume is not available as part of the SWT toolkit.

Also, does SWT class library have an equivalent for a Spinner widget in Swing?

There are Calendar and spinner custom widgets in SWT available on the net but they have certaim license issues...

Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

There is no Spinner or Calendar controls for SWT. There is an article on writing your own SWT widgets on I believe there is even an example on how to create your own Spinner control. I would search on for this article and go from there.
Mike Evans

Joined: Jul 16, 2002
Posts: 8
The following article demonstrates how to wrap a native spinner control, at least in Windows and Motif.


Mike E.
John Kouch

Joined: Dec 10, 2002
Posts: 4
You can get a Calendar(or datepicker) widget here ---> SWT DatePicker
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

I also ran across this in case you want something very specific to your needs. I wonder why JFace doesn't have a component yet. However, technically, core Swing doesn't have one yet either which is pretty pathetic.

GenRocket - Experts at Building Test Data
Atul Shrivastava

Joined: Jan 12, 2009
Posts: 19

You can use DateTime widget for this:

Usage examples:

1. Monthview calendar, which is always open - DateTime calender = new DateTime(form.getBody(), SWT.CALENDAR);

2. Date only, collapsed - DateTime date = new DateTime(form.getBody(), SWT.DATE);

3. Time only, collapsed - DateTime time = new DateTime(form.getBody(), SWT.TIME);

4. Date and Time, with dropDown - DateTime dateDropDown = new DateTime(form.getBody(), SWT.DATE | SWT.DROP_DOWN);

OCP (SCJP) - Java 1.6
I agree. Here's the link:
subject: Does SWT provide a Calendar Widget?
It's not a secret anymore!