Class WAbstractSpinBox

Direct Known Subclasses:
WDoubleSpinBox, WSpinBox

public abstract class WAbstractSpinBox extends WLineEdit
An abstract spin box.

Although the element can be rendered using a native HTML5 control, by default it is rendered using an HTML4 compatibility workaround which is implemented using JavaScript and CSS, as most browsers do not yet implement the HTML5 native element.

  • Constructor Details

  • Method Details

    • setNativeControl

      public void setNativeControl(boolean nativeControl)
      Configures whether a native HTML5 control should be used.

      When native, the new "number" input element, specified by HTML5 and when implemented by the browser, is used rather than the built-in element. The native control is styled by the browser (usually in sync with the OS) rather than through the theme chosen.

      The default is false (as native support is now well implemented).

    • isNativeControl

      public boolean isNativeControl()
      Returns whether a native HTML5 control is used.

      Taking into account the preference for a native control, configured using setNativeControl(), this method returns whether a native control is actually being used.

    • setPrefix

      public void setPrefix(CharSequence prefix)
      Sets a prefix.

      Option to set a prefix string shown in front of the value, e.g.:

       spinBox.setPrefix("$ ");

      The default prefix is empty.

      Note: Not supported by the native controls.

    • getPrefix

      public WString getPrefix()
      Returns the prefix.

      See Also:
    • setSuffix

      public void setSuffix(CharSequence suffix)
      Sets a suffix.

      Option to set a suffix string shown to the right of the value, e.g.:

       spinBox.setSuffix(" crates");

      The default suffix is empty.

      Note: Not supported by the native controls.

    • getSuffix

      public WString getSuffix()
      Returns the suffix.

      See Also:
    • setText

      public void setText(String text)
      Description copied from class: WLineEdit
      Sets the content of the line edit.

      The default value is "".

      setText in class WLineEdit
      See Also:
    • validate

      public ValidationState validate()
      Description copied from class: WFormWidget
      Validates the field.

      validate in class WLineEdit
      See Also:
    • refresh

      public void refresh()
      Description copied from class: WWidget
      Refresh the widget.

      The refresh method is invoked when the locale is changed using WApplication#setLocale() or when the user hit the refresh button.

      The widget must actualize its contents in response.

      Note: This does not rerender the widget! Calling refresh() usually does not have any effect (unless you've reimplemented refresh() to attach to it an effect).

      refresh in class WFormWidget
    • jsValueChanged

      public JSignal2<Integer,Integer> jsValueChanged()
    • 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.

      render in class WLineEdit
    • setFormData

      protected void setFormData(WObject.FormData formData)
      setFormData in class WLineEdit
    • getTextFromValue

      protected abstract String getTextFromValue()
    • getValidateRange

      protected abstract WValidator.Result getValidateRange()
    • boxPadding

      protected int boxPadding(Orientation orientation)
      Description copied from class: WWidget
      Returns the widget's built-in padding.

      This is used by the layout managers to correct for a built-in padding which interferes with setting a widget's width (or height) to 100%.

      A layout manager needs to set the width to 100% only for form widgets (WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the padding (the default implementation returns 0).

      For form widgets, the padding depends on the specific browser/platform combination, unless an explicit padding is set for the widget.

      When setting an explicit padding for the widget using a style class, you will want to reimplement this method to return this padding in case you want to set the widget inside a layout manager.

      boxPadding in class WLineEdit
      See Also: