Class CalendarBox


  • public class CalendarBox
    extends Window
    The Calendar class displays a calendar with buttons used to advance the month and the year. It uses the Date class for all operations.
    Instead of create a new instance (which consumes memory), you may use the Edit's static field calendar

    If there is something in the edit box which poped up the calendar, the clear button will clear it. Cancel will leave whatever was in there.

    The month can be changed via keyboard using the left/right keys, and the year can be changed using up/down keys.

    • Field Detail

      • YEAR_ARRAY_LENGTH

        public static int YEAR_ARRAY_LENGTH
        Defines the array length of year window. If array length is 20, and current year is 2010, the list goes from 2000 to 2019.
        Since:
        TotalCross 1.66
      • canceled

        public boolean canceled
        True if the user had canceled without selecting
      • weekNames

        public static java.lang.String[] weekNames
        The 7 week names painted in the control.
      • todayClearCancel

        public static java.lang.String[] todayClearCancel
        The labels for Today, Clear and Cancel.
      • yearMonth

        public static java.lang.String[] yearMonth
        The labels between the arrows: Month, Year
    • Constructor Detail

      • CalendarBox

        public CalendarBox()
        Constructs Calendar set to the current day.
    • Method Detail

      • getSelectedDate

        public Date getSelectedDate()
        Returns the selected Date.
        Returns:
        Date object set to the selected day, or null if an error occurs.
      • setSelectedDate

        public void setSelectedDate​(Date d)
        Sets the current day to the Date specified. If its null, sets the date to today.
      • onEvent

        public void onEvent​(Event event)
        Description copied from class: Control
        Called to process key, pen, control and other posted events.
        Overrides:
        onEvent in class Control
        Parameters:
        event - the event to process
        See Also:
        Event, KeyEvent, PenEvent
      • onPaint

        public void onPaint​(Graphics g)
        Description copied from class: Container
        Draws the border (if any). If you override this method, be sure to call super.onPaint(g);, or the border will not be drawn.
        Overrides:
        onPaint in class Container
        Parameters:
        g - the graphics object for drawing
        See Also:
        Graphics
      • onPopup

        protected void onPopup()
        Description copied from class: Window
        Placeholder called imediatly before the popup began. The default implementation does nothing.
        Overrides:
        onPopup in class Window
      • onUnpop

        protected void onUnpop()
        Description copied from class: Window
        Placeholder called imediatly before the unpop began. The default implementation does nothing.
        Overrides:
        onUnpop in class Window
      • postUnpop

        protected void postUnpop()
        Description copied from class: Window
        Placeholder called after the unpop is done and after the repaint of the other window. The default implementation does nothing.
        Overrides:
        postUnpop in class Window