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.
Use JSpinner with SpinnerNumberModel
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 .
( Click to enlarge the demo screenshot. )
I think you will like the ease of JCalendar. It offers a JDateChooser, a JDayChooser or a JSpinnField, written by Kai Toedter', available here: JCalendar 1.4.
You can get your dates like this:
java.util.Date fromDate = jDateChooser1.getDate();
JSpinnField lets you set max and min values easily:
jSpinField1.setMaximum(59);
jSpinField1.setMinimum(0);
Related
I would like the DateField to be defaulted to my user's timezone. I've tried DateField.setZoneId() but this really didn't seem to do anything. I then tried to do DateField.setDefaultValue(LocalDateAdjustedForTimeZone) which mostly worked in that the blue box was correctly highlighted but the black outline remained under the server's timezone.
As far as I can see in the Vaadin client component VAbstractCalendarPanel#buildCalendarBody(), there's no way to influence which day is marked with the today CSS style v-datefield-calendarpanel-day-today. The client component Java code about determining "today" looks like:
final Date tmp = new Date();
final Date today = new Date(tmp.getYear(), tmp.getMonth(), tmp.getDate());
So I guess when it's translated to JavaScript it will take the current date on the browser's system.
However, as a workaround you can at least adapt the CSS styles to hide the today marker. I wonder why Vaadin did not think about your use case (which is mine, too). Can you open an issue at Vaadin please?
I want to make a custom date-picker for android and I need to change something in datepicker.class file in android.widget package. In fact, I want to change the year and month for solar hijri calendar.
I found source code of datepicker.java in http://alvinalexander.com/java/jwarehouse/android/core/java/android/widget/DatePicker.java.shtml - but I don't know how to change and replace it with default android class. Does anybody know how to do this?
The dirty way to do this is to copy the source code for the datepicker class, and rename/modify it as your own class for the hijri calendar. You could then import or extend this new class to work with your code.
You could use this custom view which implement jalali date on it
https://github.com/alibehzadian/PersianDatePicker
you could just copy the classes ,layout , values on it and paste them in your project and now you have datepicker for jalali date jsut follow the usage instructions on the provided link
I want to show holidays and weekends (Fridays & Saturdays) in custom style. Is there any attribute provided by PrimeFaces to do this, or what should I do to build a custom component from existing <p:calendar>.
Without using javascript or jquery.
Thanks in advance.
Regards,
Sunny
I think can achieve without writing a custom core custom component.
Create a composite component and use java script to highlight the custom dates you are interested in.
onClick(call the below function on P:cal)
function updatedaysHighlighter(){
var rows = document.getElementById('ui-datepicker-div').getElementsByTagName("tr");
if(days.length>1) {
alert(days[4].innerHTML);
}
}
You can try playing with td and update the class value for each td as like you want.
Its not supported by primeface...
There is a New Feature Request about this exact feature , and one of the comments requested holidays too
You can vote for it Issue 1805: New feature for Calendar: receive a list of Dates to highlight them
But in the meanwhile you better do it yourself using jquery (highlight holidays in datepicker jquery)
I've got a DateTime (SWT.TIME) and want to know if the hours or minutes or seconds are selected.
I would like to get this information because I want that the User can scroll the mouse wheel in order to change the selected values accordingly.
Unfortunately I couldn't find any way to get the selected element of the DateTime Control. Does anybody have an idea?
DateTime provides many methods for getting the selected date. Like getHours, getMinutes, getDay, and so on. It's unclear to me what's your exact question, but appropiate setters are there as well.
I want to implement a date chooser using a JSlider. The user should be able to use the slider to freely choose between two previously known dates. I've seen examples like this one:
But I want to do the same, using only one slider. The minimal distance between two points (tick) should be one day. Any hints how to implement that?
If you want to have a slider with min = 1.1.2012 and max = 10.1.2012 just create a slider with min = 0 and max = number of days in between, then add the selected number to 1.1.2012.
I assume 10.1.2012 means January 10th, thus your slider would have min = 0 and max = 9. Then set the labels accordingly.
I can't to image how to do that with one JSlider, because there you'd have bunch of days, there are some workarounds for Double/RangeSlider, but I think better and easiest would be implements JSpinner with SpinnerDateModel, or best options is look for Custom Java Calendar or DatePicker
EDIT (#Robin)
First to answer your question: you can just use a JSlider, use the number of days between your start and end date to determine the range, and use custom labels (by using for example the setLabelTable method)
Now for user-friendliness, avoid this since
Nobody is familiar with this concept. Every site/application nowadays uses a textfield, most of the time in combination with a calendar widget. That is what users expect, not a slider
It will be hard to get all dates as labels on the slider due to the limited width. This means that a user have to interpolate / count to select his correct date
If you stick to the slider approach, at least consider to add a textfield as well. Even a non-editable text field which shows the currently selected date would be a huge improvement over a slider (see point 2)