The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » SwingLabs

Thread: Inputting intervals via JXDatePicker?

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Last Post: Aug 20, 2008 6:41 AM by: osbald
osbald

Posts: 853
Inputting intervals via JXDatePicker?
Posted: Aug 19, 2008 5:08 AM
  Click to reply to this thread Reply

Wondering if JXDatePicker can be used to pick a range of dates instead of just one? Certainly JXMonthView is happy when picking ranges. The possible edge case I've been working on is a start & end JXDatePicker pair, the interesting twist comes from them both sharing the same DateSelectionModel and having that model set to SINGLE_INTERVAL_SELECTION.

This almost worked except the end date appears as the start date, which I've traced down to a getMonthView().getSelectionDate() in the BasicDatePickerUI:
    private void updateEditorValue() {
        datePicker.getEditor().setValue(datePicker.getMonthView().getSelectionDate());
    }

- unfortunately it's private..?

An alternative solution I've been thinking about is that single selections in start & end picker act on their corresponding interval ends. So interval selections on either work as above, but each end can be selected independently (makes life easier when crossing month boundaries). The shared model won't work in this case as a single selection changes both intervals. Two separate models to keep in sync or a custom one? In fact what is the commit event for a date? a PropertyChange on the JXDatePicker? the MonthView fires DateSelectionEvent during the selection process which is rather like isAdjusting().

osbald

Posts: 853
Re: Inputting intervals via JXDatePicker?
Posted: Aug 19, 2008 5:15 AM   in response to: osbald
  Click to reply to this thread Reply

hmm suppose if I do have two models and do all the syncing manually I could redefine the value of getSelectionDate() on the until model? ..stop looking at the source?

argh! maybe not it's calling getFirstSelectionDate() on the model.. that'd be very confusing even if it did work.



Message was edited by: osbald

osbald

Posts: 853
Re: Inputting intervals via JXDatePicker?
Posted: Aug 20, 2008 6:41 AM   in response to: osbald
  Click to reply to this thread Reply

So can I (should I) make updateEditorValue() protected which'll at least get me to the next stumbling block. Or would I be better off with a new Component, only it's not really a single component more two interlinked ones that ought to delegate their sizing & positions to the layout manager.




 XML java.net RSS