Class MaterialTimePicker

java.lang.Object
com.codename1.ui.Component
com.codename1.ui.Container
com.codename1.ui.spinner.MaterialTimePicker
All Implemented Interfaces:
Animation, Editable, StyleListener, InternalPickerWidget, Iterable<Component>

public class MaterialTimePicker extends Container implements InternalPickerWidget

A time picker in the Material 3 style: the hour and the minute in large type over a clock face. The hand is dragged to the hour, the face then turns to minutes, and a keyboard button swaps the face for two text fields.

A Picker opens one in a dialog when the theme constant pickerStyle is material. It is a component like any other and can be placed in a form directly. The value is an Integer, the minutes since midnight, as it is for the time of a Picker.

With setShowMeridiem(true) the face has twelve hours and AM and PM beside the time; without, it has two rings, the afternoon inside.

The hours of a Material time picker The minutes Twenty four hours

Under a mouse the number the pointer is over is marked. The hand follows a finger as it is dragged, and turns by the shorter way round to a time that is set any other way: the minutes after an hour is chosen, a time typed in, a call to setTime.

The hand turning from ten to two, as four stopped frames

Styling

PickerMaterialOverline is the small title. PickerMaterialTimeField is the hour and the minute, its selected style the one the face is showing, and PickerMaterialTimeSeparator the colon between them. PickerMaterialPeriod is AM and PM. PickerMaterialDial is the face: its background the disc and its foreground the numbers, and its selected style the hand, with the foreground the number under it. Its disabled style is an hour outside the range. PickerMaterialButton is the keyboard button and PickerMaterialField a text field.

  • Constructor Details

    • MaterialTimePicker

      public MaterialTimePicker()
      A picker showing midnight on a 24 hour face.
  • Method Details

    • getHour

      public int getHour()
      The hour of the day, 0 to 23.
    • getMinute

      public int getMinute()
    • setTime

      public void setTime(int hourOfDay, int minuteOfHour)
      Sets the time. The hour is of the day, 0 to 23, whatever the face shows; an hour outside the range is brought to the nearest one in it. The minute is kept as it is given: the step is where the hand stops when it is turned, and a time that is only looked at is not changed by having been shown.
    • getValue

      public Object getValue()
      The minutes since midnight, as an Integer.
      Specified by:
      getValue in interface InternalPickerWidget
    • setValue

      public void setValue(Object value)
      Sets the time from the minutes since midnight. Anything that is not an Integer is ignored.
      Specified by:
      setValue in interface InternalPickerWidget
    • isShowMeridiem

      public boolean isShowMeridiem()
      Whether the face has twelve hours with AM and PM beside the time.
    • setShowMeridiem

      public void setShowMeridiem(boolean v)
    • setMinuteStep

      public void setMinuteStep(int step)
      The minutes the hand stops at: 5 for every five minutes, 1 for all.
    • getMinuteStep

      public int getMinuteStep()
    • setHourRange

      public void setHourRange(int min, int max)
      The hours that can be chosen: from min up to but not max. A negative min removes the limit.
    • setTitle

      public void setTitle(String title)
      The small title over the time: "Select time" unless set.
    • getTitle

      public String getTitle()
    • addActionListener

      public void addActionListener(ActionListener l)
      Told when the user chooses another time.
    • removeActionListener

      public void removeActionListener(ActionListener l)
    • isInputMode

      public boolean isInputMode()
      Whether the time is typed and not picked from the face.
    • setInputMode

      public void setInputMode(boolean v)
    • getInputModeButton

      public Button getInputModeButton()
      The button that swaps the face for text fields. It is under the face until something takes it: a dialog puts it beside its own buttons.
    • setAnimationTime

      public void setAnimationTime(long millis)
      Stops the clock the hand turns by at a time, for a screenshot of the turn or a test of it. A negative value returns to the clock.