Class WDatePicker


public class WDatePicker extends WCompositeWidget
A date picker.

A date picker shows a line edit and an icon which when clicked popups a WCalendar for editing the date. Any date entered in the line edit is reflected in the calendar, and vice-versa.

Each of these widgets may be accessed individually (getLineEdit(), getCalendar(), and getDisplayWidget()) and there is a constructor that allows you to specify an existing line edit and display widget.

The date format used by default is "dd/MM/yyyy" and can be changed using setFormat(). At any time, the date set may be read using getDate(), or can be changed using setDate().

i18n

Internationalization of WDatePicker is mostly handled through the internationalization mechanism of WDate.

  • Constructor Details

    • WDatePicker

      public WDatePicker(WContainerWidget parentContainer)
      Create a new date picker.

      This constructor creates a line edit with an icon that leads to a popup calendar. A WDateValidator is configured for the line edit.

    • WDatePicker

      public WDatePicker()
      Create a new date picker.

      Calls this((WContainerWidget)null)

    • WDatePicker

      public WDatePicker(WLineEdit forEdit, WContainerWidget parentContainer)
      Create a new date picker for a line edit.

      This constructor creates an icon that leads to a popup calendar.

      The forEdit argument is the lineEdit that works in conjunction with the date picker. This widget does not become part of the date picker, and may be located anywhere else.

    • WDatePicker

      public WDatePicker(WLineEdit forEdit)
      Create a new date picker for a line edit.

      Calls this(forEdit, (WContainerWidget)null)

    • WDatePicker

      public WDatePicker(WInteractWidget displayWidget, WLineEdit forEdit, WContainerWidget parentContainer)
      Create a new date picker for existing line edit and with custom display widget.

      The displayWidget is a button or image which much be clicked to open the date picker.

      The forEdit argument is the lineEdit that works in conjunction with the date picker.

    • WDatePicker

      public WDatePicker(WInteractWidget displayWidget, WLineEdit forEdit)
      Create a new date picker for existing line edit and with custom display widget.

      Calls this(displayWidget, forEdit, (WContainerWidget)null)

  • Method Details

    • remove

      public void remove()
      Destructor.
      Overrides:
      remove in class WCompositeWidget
      See Also:
    • getDateValidator

      public WDateValidator getDateValidator()
      Returns the validator.

      Most of the configuration of the date edit is stored in the validator.

    • setFormat

      public void setFormat(String format)
      Sets the format used for parsing or writing the date in the line edit.

      Sets the format used for representing the date in the line edit. If the line edit has a WDateValidator configured for it, then also there the format is updated.

      The default format is 'dd/MM/yyyy'.

      See Also:
    • getFormat

      public String getFormat()
      Returns the format.

      See Also:
    • getCalendar

      public WCalendar getCalendar()
      The calendar widget.

      Returns the calendar widget.

    • getLineEdit

      public WLineEdit getLineEdit()
      The line edit.

      Returns the line edit which works in conjunction with this date picker.

    • getDisplayWidget

      public WInteractWidget getDisplayWidget()
      The display widget.

      Returns the icon which activates the popup.

    • getPopupWidget

      public WPopupWidget getPopupWidget()
      The popup widget.

      Returns the popup widget that contains the calendar.

    • getDate

      public WDate getDate()
      The current date.

      Reads the current date from the getLineEdit().

      Returns null if the date could not be parsed using the current getFormat().

      See Also:
    • setDate

      public void setDate(WDate date)
      Sets the current date.

      Does nothing if the current date is Null.

      See Also:
    • setEnabled

      public void setEnabled(boolean enabled)
      Sets whether the widget is enabled.

      This is the oppositie of setDisabled().

    • setDisabled

      public void setDisabled(boolean disabled)
      Description copied from class: WWidget
      Sets whether the widget is disabled.

      Enables or disables the widget (including all its descendant widgets). setDisabled(false) will enable this widget and all descendant widgets that are not disabled. A widget is only enabled if it and all its ancestors in the widget tree are disabled.

      Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.

      Overrides:
      setDisabled in class WCompositeWidget
      See Also:
    • setHidden

      public void setHidden(boolean hidden, WAnimation animation)
      Hide/unhide the widget.
      Overrides:
      setHidden in class WCompositeWidget
    • setBottom

      public void setBottom(WDate bottom)
      Sets the bottom of the valid date range.
    • getBottom

      public WDate getBottom()
      Returns the bottom date of the valid range.
    • setTop

      public void setTop(WDate top)
      Sets the top of the valid date range.
    • getTop

      public WDate getTop()
      Returns the top date of the valid range.
    • changed

      public Signal changed()
      Signal emitted when the value has changed.

      This signal is emitted when a new date has been entered (either through the line edit, or through the calendar popup).

    • setPopupVisible

      public void setPopupVisible(boolean visible)
      Shows or hides the popup.
    • popupClosed

      public Signal popupClosed()
      A signal which indicates that the popup has been closed.

      The signal is only fired when the popup has been closed by the user.

    • render

      protected void render(EnumSet<RenderFlag> flags)
      Description copied from class: WWidget
      Renders the widget.

      This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

      The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

      Overrides:
      render in class WCompositeWidget