Module MaterialFX

Class MFXStepperSkin

java.lang.Object
javafx.scene.control.SkinBase<MFXStepper>
io.github.palexdev.materialfx.skins.MFXStepperSkin
All Implemented Interfaces:
Skin<MFXStepper>

public class MFXStepperSkin extends SkinBase<MFXStepper>
This is the implementation of the Skin associated with every MFXStepper.

It is basically a BorderPane with three sections: top, center, bottom.

At the top there is the HBox that contains the MFXStepperToggles and the progress bar which is realized by using a group and two rectangles. One rectangle is for the background/track and the other is the progress/bar. The bar is manually adjusted according to the current selected toggle, its width is set using MFXStepperToggle.getGraphicBounds() (+10 to ensure that there's no white space between the bar and the toggle).

At the center there is a StackPane, it is the content pane namely the node that will contain the content specifies by each stepper toggle. The style class is set to "content-pane".

At the bottom there is the HBox that contains the previous and next buttons. The style class is set to "buttons-box".

The stepper skin is rather delicate because the progress bar is quite hard to manage since every layout change can potentially break it. The skin updates the layout by adding a listener to the Parent.needsLayoutProperty(). When it changes the progress must be computed again with computeProgress(). A workaround is also needed in case the progress bar is animated and the layout changes. Without the workaround the progress bar layout is re-computed by using the animation so the reposition process is not instantaneous. To fix this annoying UI issue a boolean flag (buttonWasPressed) is set to true only when buttons are pressed and then set to false right after the layout update, so every layout change is done without playing the animation.
See Also:
  • Constructor Details

    • MFXStepperSkin

      public MFXStepperSkin(MFXStepper stepper)
  • Method Details

    • buildRectangle

      protected Rectangle buildRectangle(String styleClass)
      Responsible for building the track and the bar for the progress bar.
    • computeMinWidth

      protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
      Overrides:
      computeMinWidth in class SkinBase<MFXStepper>
    • computeMinHeight

      protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
      Overrides:
      computeMinHeight in class SkinBase<MFXStepper>
    • computeMaxWidth

      protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
      Overrides:
      computeMaxWidth in class SkinBase<MFXStepper>
    • computeMaxHeight

      protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
      Overrides:
      computeMaxHeight in class SkinBase<MFXStepper>
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Skin<MFXStepper>
      Overrides:
      dispose in class SkinBase<MFXStepper>
    • layoutChildren

      protected void layoutChildren(double x, double y, double w, double h)
      Overrides:
      layoutChildren in class SkinBase<MFXStepper>