I want to create component in Swing where text field takes only date type value.
+1
A:
Take a look at SwingX library. It is free and has a very good component called JXDatePicker
eugener
2010-06-14 21:09:06
Thanks for pointing out this library... looks great...
Pete
2010-08-05 19:18:36
A:
There are a few options for you:
- create an editable text field that parses for a date format on insert, using a
DocumentListener
or a customDocument
- create an editable text field that gets parsed for a valid date format on loss of focus or validated on an
ActionEvent
triggered by a submit button - create a non-editable text field with spinner buttons that increment/decrement the date string that you define
- use a 3rd party library as @eugener suggests
If you have a specific problem creating your component, please post the code you have been working on and we will be happy to help further.
akf
2010-06-15 01:58:20
+2
A:
You could use JFormattedTextField
, setting your format for the date. Works without using anything outside of the JRE, but might not be the most usable option.
Otherwise do what eugener said and use SwingX's JXDatePicker
or JIDE's DateComboBox
.
Trejkaz
2010-08-05 05:10:25