From: jc_usernet on
Hello.
Just a quick question. Where can I find a good library class that
performs the operation of allowing me to easily input a date and time
on a GUI (with other swing components)?
I expected to find this in the swing / Java native presentation;

java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)

Regards JC.....
From: markspace on
jc_usernet wrote:

> I expected to find this in the swing / Java native presentation;


You would be correct.


new JFormattedTextField( new SimpleDateFormat( "mm/dd/yyyy" ) );

and

Calandar now = Calendar.getInstance();
Calandar earliestDate = ...
Calendar latestDate = ...
SpinnerModel model = new SpinnerDateModel( now.getTime(),
earliestDate.getTime(), latestDate.getTime(), Calendar.WEEK_OF_YEAR );
JSpinner spinner = new JSpinner( model );


In general, the Java docs are your friend. However, it can be difficult
to find a class if you don't know what to look for. I used Learning
Java by O'Reilly, 3rd ed., to look these up. Learning Java is a good
reference to keep around, and it does seem to cover the most important
classes, and give examples of their use, which I've copied partially for
you above.

From: John B. Matthews on
In article
<62ef6df2-7edc-46fd-872e-2220f23ee465(a)f17g2000prh.googlegroups.com>,
jc_usernet <jc_usernet(a)aanet.com.au> wrote:

> Hello.
> Just a quick question. Where can I find a good library class that
> performs the operation of allowing me to easily input a date and time
> on a GUI (with other swing components)?
> I expected to find this in the swing / Java native presentation;
>
> java version "1.6.0_14"
> Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
> Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)

In addition to the date spinner suggested by markspace, here's an
example of using Input verifier to accommodate multiple formats:

<http://groups.google.com/group/comp.lang.java.programmer/msg/d9f7a7702139b48f>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
From: markspace on
John B. Matthews wrote:
>
> In addition to the date spinner suggested by markspace, here's an
> example of using Input verifier to accommodate multiple formats:


Just in case I wasn't very clear, I gave two solutions:

1. Use JFormattedTextField with SimpleDateFormat.
2. Use JSpinner.


I guess the "and" in the middle of that wasn't too indicative of a
change in thought.
From: John B. Matthews on
In article <hl4u4e$2qu$1(a)news.eternal-september.org>,
markspace <nospam(a)nowhere.com> wrote:

> John B. Matthews wrote:
> >
> > In addition to the date spinner suggested by markspace, here's an
> > example of using Input verifier to accommodate multiple formats:
>
>
> Just in case I wasn't very clear, I gave two solutions:
>
> 1. Use JFormattedTextField with SimpleDateFormat.
> 2. Use JSpinner.
>
>
> I guess the "and" in the middle of that wasn't too indicative of a
> change in thought.

No, I read your response carelessly. On reflection, I see
SimpleDateFormat as foundational to both spinner and verifier.
I think you are right to emphasize it.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>