CambodiaDJ-Raven/swing-datetime-picker
Java swing flatlaf datetime picker
Featured achievements
The project's latest awards
#1 Repository of the month
#1 Repository of the month
#1 Repository of the month
Swing Datetime Picker
A simple datetime picker implementation using Java Swing, built with the flatlaf UI library and miglayout for layout management.
This project provides a datetime picker component that can be easily integrated into Java Swing applications. It leverages flatlaf for a modern look and miglayout for flexible and easy-to-use layout management.

Installation
Add the dependency
<dependency>
<groupId>io.github.dj-raven</groupId>
<artifactId>swing-datetime-picker</artifactId>
<version>2.1.3</version>
</dependency>
Snapshots
To get the latest updates before the release, you can use the snapshot version from Sonatype Central
<repositories>
<repository>
<name>Central Portal Snapshots</name>
<id>central-portal-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
</repository>
</repositories>
Add the snapshot version
<dependency>
<groupId>io.github.dj-raven</groupId>
<artifactId>swing-datetime-picker</artifactId>
<version>2.1.4-SNAPSHOT</version>
</dependency>
Usage TimePicker
| Method | Return Value | Description |
|---|---|---|
| now() | set the time to current local time | |
| setSelectedTime(LocalTime time) | set the time to a specific value | |
| clearSelectedTime() | clear the selected time | |
| isTimeSelected() | boolean | check time is selected |
| getSelectedTime() | LocalTime | return the selected time |
| getSelectedTimeAsString() | String | return selected time as string |
| addTimeSelectionListener(TimeSelectionListener event) | add event time selection | |
| removeTimeSelectionListener(TimeSelectionListener event) | remove event time selection | |
| setOrientation(int orientation) | SwingConstants.VERTICAL or SwingConstants.HORIZONTAL | |
| setEditor(JFormattedTextField editor) | display the selected time on the editor and allow to edit time | |
| setTimeSelectionAble(TimeSelectionAble dsb) | set time selection able | |
| set24HourView(boolean hour24) | set time to 24h selection view | |
| is24HourView() | boolean | return ture is 24h selection view |
| showPopup() | if time have editor, timepicker will show up with popup menu | |
| closePopup() | close editor popup | |
| setColor(Color color) | change base color | |
| setEditorIcon(Icon icon) | change icon to editor | |
| setEditorValidation(boolean validation) | validation editor | |
| void setValidationOnNull(boolean validationOnNull) | validation editor on null selection | |
| void showPopup(Component component) | show timePicker with popup without editor | |
| void setPopupSpace(Point popupSpace) | set the popup space with component or editor | |
| void toDateSelectionView() | show date selection state |
Usage DatePicker
| Method | Return Value | Description |
|---|---|---|
| now() | set the date to current local date | |
| setToBack() | slide panel to back with animation | |
| setToForward() | slide panel to forward with animation | |
| selectMonth() | show panel month slide with animation | |
| selectYear() | show panel year slide with animation | |
| slideTo(LocalDate date) | slide panel to specific date | |
| getDateSelectionMode() | DateSelectionMode | return the date selection mode |
| setDateSelectionMode(DateSelectionMode mode) | set mode SINGLE_DATE_SELECTED or BETWEEN_DATE_SELECTED | |
| setSelectedDate(LocalDate date) | set the date to a specific value | |
| setSelectedDateRange(LocalDate from, LocalDate to) | set the date range to a specific value | |
| setEditor(JFormattedTextField editor) | display the selected date on the editor and allow to edit date | |
| setDateSelectionAble(DateSelectionAble dsb) | set date selection able | |
| showPopup() | if date have editor, datepicker will show up with popup menu | |
| closePopup() | close editor popup | |
| setSeparator(String separator) | set separator to between date | |
| setUsePanelOption(boolean usePanelOption) | set datepicker use panel option | |
| setCloseAfterSelected(boolean closeAfterSelected) | if true popup will close after selected date | |
| clearSelectedDate() | clear the selected date | |
| isDateSelected() | boolean | check date is selected |
| getSelectedDate() | LocalDate | return the selected date |
| getSelectedDateRange() | LocalDate[] | return the selected date range |
| getSelectedDateAsString() | String | return selected date as string |
| addDateSelectionListener(DateSelectionListener evt) | add event date selection | |
| removeDateSelectionListener(DateSelectionListener evt) | remove event date selection | |
| selectCurrentMonth() | select from first day to current day in current month | |
| setColor(Color color) | change base color | |
| setEditorIcon(Icon icon) | change icon to editor | |
| setDateFormat(String format) | change date format | |
| setEditorValidation(boolean validation) | validation editor | |
| void setValidationOnNull(boolean validationOnNull) | validation editor on null selection | |
| void setAnimationEnabled(boolean animationEnabled) | enable or disabled the animation | |
| void setPanelDateOptionLabel(PanelDateOptionLabel opt) | set new panel date option label | |
| void setStartWeekOnMonday(boolean startWeekOnMonday) | show the monday is the start of the week | |
| void showPopup(Component component) | show datePicker with popup without editor | |
| void setPopupSpace(Point popupSpace) | set the popup space with component or editor | |
| void setHourSelectionView(boolean hourSelectionView) | show hour or minute selection state | |
| void setSelectionArc(float selectionArc) | set date selection border arc | |
| void setDefaultDateCellRenderer(DefaultDateCellRenderer renderer) | set date cell renderer to paint custom graphics | |
| public static void setDefaultWeekdays(String[] defaultWeekdays) | static method for set default label week days | |
| public static void setDefaultMonths(String[] defaultMonths) | static method for set default label months | |
| public static String[] getDefaultWeekdays() | static method for get default label week days | |
| public static String[] getDefaultMonths() | static method for get default label months |
Library Resources
Similar Projects
Discover other similar projects and AI models.
⭐🎉一个高颜值日期时间选择器;极简API,内置弹窗,支持农历日期显示,适配深色模式,可动态配置样式及主题,选择器支持完全自定义UI。
JavaScript date picker, support range, time, year, month. JavaScript 日期选择器插件,支持范围、日期、时间、月份、年份等多种类型。
This is a picker view for android , support linkage effect, timepicker and optionspicker.(时间选择器、省市区三级联动)
安卓选择器类库,包括日期及时间选择器(可用于出生日期、营业时间等)、单项选择器(可用于性别、民族、职业、学历、星座等)、二三级联动选择器(可用于车牌号、基金定投日期等)、城市地址选择器(分省级、地市级及区县级)、数字选择器(可用于年龄、身高、体重、温度等)、日历选日期择器(可用于酒店及机票预定日期)、颜色选择器、文件及目录选择器、图片选择器等……WheelPicker/DatePicker/TimePicker/OptionPicker/NumberPicker/LinkagePicker/AddressPicker/CarPlatePicker/CalendarPicker/ColorPicker/FilePicker/ImagePicker etc.
FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
Swing toast notifications use for java desktop application