Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swing time picker

Im looking for a pretty and decent time picker component. There are a lot of alternatives for date picking on Swing but no for time.

I've seen nice Date/Time components picking on JQuery ( for example: http://trentrichardson.com/examples/timepicker/ ). There is something similar on Swing?

Thanks in advance.

like image 215
Fsero Avatar asked Sep 28 '11 07:09

Fsero


People also ask

Why J is used in Swing?

The J identifies all Swing components. Swing used to be marketed as Java Foundation Classes, before it became an integral part of the JDK. +1: It also made it less of a headache to include both AWT classes and Swing classes in the same source file.

What is JSpinner in Java?

JSpinner is a part of javax. swing package. JSpinner contains a single line of input which might be a number or a object from an ordered sequence. The user can manually type in a legal data into the text field of the spinner. The spinner is sometimes preferred because they do not need a drop down list.

What is the model in Swing?

Most Swing components have models. A button ( JButton ), for example, has a model (a ButtonModel object) that stores the button's state — what its keyboard mnemonic is, whether it's enabled, selected, or pressed, and so on. Some components have multiple models.


2 Answers

Use JSpinner with SpinnerNumberModel

like image 142
Ashwini Raman Avatar answered Sep 28 '22 08:09

Ashwini Raman


I would suggest the TimePicker component of the LGoodDatePicker library. The time can be chosen with the (default) "drop down" menu, with (optional) "spinner" style buttons, or both.

Fair disclosure: I'm the primary developer.

The TimePicker can be customized with optional settings. A few of the settings are the language (locale), default times in the drop down menu, fonts and colors, display/menu/parsing formats, 12 or 24 hour clock, seconds or nanoseconds precision, and so forth.

The library also includes the DatePicker and DateTimePicker components. All three components are easy to use. (They can each be instantiated with a single line of code.)

I've pasted screenshots of the components and the demo application below.

Project Home page: https://github.com/LGoodDatePicker/LGoodDatePicker .

DateTimePicker screenshot

( Click to enlarge the demo screenshot. ) Demo screenshot

like image 45
BlakeTNC Avatar answered Sep 28 '22 06:09

BlakeTNC