Spin Control

Sep 18, 2006 00:25

After some soul-searching I have made a decision to create my own spin control. It turned out to be much easier than to mold the JSpinner to my requirements. Key solution elements:

  • TSpinBox - my own spin control. Implemented as a composite control.
    • Consists of a JTextField, and 2 TButtons.
    • TButtons are layed out using a GridBagLayout (I am sure there must be a better way)
    • TButtons are given special borders (small insets to make them fit nicely)
    • TButtons are not focusable
    • Implemented a hand-drawn ArrowIcon for the buttons
  • ISpinBoxModel my own model for the TSpinBox
    • Provided by IFormatter
    • Extends the SpinnerModel interface, but adds spinUp, spinDown methods that actually change the value and alert all listeners
    • First class to implement this is the SelectListModel: now it sends updates to spin ChangeEvent listeners (whenever the current slected value is not null) and provides the ability to navigate by spin.
Previous post Next post
Up