Hi Sanjaya,
The setStart method works fine for Date. Try the following example:
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(0);
calendar.set(Calendar.HOUR_OF_DAY, 2);
SpinnerDateModel model = new SpinnerDateModel(new Date(),
calendar.getTime(), null,
Calendar.HOUR_OF_DAY);
JSpinner spinner = new JSpinner(model);
JSpinner.DateEditor editor = new
JSpinner.DateEditor(spinner, "HH:mm");
spinner.setEditor(editor);
frame.add(spinner, BorderLayout.NORTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
}
});
Regards, Pavel
Hi Pavel,
Thank you for the reply.But It doesn't support when I am trying to
set the start time.model.setStart(Comparable comparable) doesn't
support for a time.But for Date.Can you explain me bit using an
example?
Thank you very much
Regards
Sanjaya
On Tue, Jan 24, 2012 at 5:04 PM, Pavel Porvatov
<[email protected]> wrote:
Hi Sanjaya,
You should use something like this:
SpinnerDateModel model = new SpinnerDateModel(new Date(),
null, null, Calendar.HOUR_OF_DAY);
JSpinner spinner = new JSpinner(model);
JSpinner.DateEditor editor = new JSpinner.DateEditor(spinner,
"hh:mm");
spinner.setEditor(editor);
To set range you can use SpinnerDateModel#setStart/setEnd methods.
Regards, Pavel
Hi all,
I want to keep two spinners in my UI which displays only the
time.(example 13:30) not the time with date.I also want to make the
1st spinner available for selecting any time value between 00:00 to
23:59.But I want to restrict the spinner 2 in such a way that only
time values after the selected value of first time spinner will be
allowed to select.
As example if I select 14:00 in spinner1 then I want to select the
time of spinner2 which is after 14:00 before 23:59.How can I restrict
spinner2.What kind of spinner should I use?
Any help please
Thank you
Sanjaya