Class Control

All Implemented Interfaces:
LayoutMeasurable, LayoutMeasurableMixin, HasBackgroundProperty, HasBlendModeProperty, HasBorderProperty, HasClipProperty, HasEffectProperty, HasHeightProperty, HasLayoutXProperty, HasLayoutYProperty, HasManagedProperty, HasMaxHeightProperty, HasMaxWidthProperty, HasMinHeightProperty, HasMinWidthProperty, HasMouseTransparentProperty, HasOnMouseClickedProperty, HasOpacityProperty, HasPaddingProperty, HasParentProperty, HasPrefHeightProperty, HasPrefWidthProperty, HasSnapToPixelProperty, HasVisibleProperty, HasWidthProperty, Styleable, EventTarget, Skinnable, INode, PreferenceResizableNode
Direct Known Subclasses:
ButtonBar, ChoiceBox, ComboBoxBase, Labeled, ProgressIndicator, ScrollPane, Separator, Slider, SplitPane, TabPane, TextInputControl

public abstract class Control extends Region implements Skinnable
Author:
Bruno Salmon
  • Property Details

  • Constructor Details

    • Control

      protected Control()
      Create a new Control.
  • Method Details

    • contextMenuProperty

      public final ObjectProperty<ContextMenu> contextMenuProperty()
      The ContextMenu to show for this control.
      Returns:
      the contextMenu property
      See Also:
    • setContextMenu

      public final void setContextMenu(ContextMenu value)
      Sets the value of the contextMenu property.
      Property description:
      The ContextMenu to show for this control.
      Parameters:
      value - the value for the contextMenu property
      See Also:
    • getContextMenu

      public final ContextMenu getContextMenu()
      Gets the value of the contextMenu property.
      Property description:
      The ContextMenu to show for this control.
      Returns:
      the value of the contextMenu property
      See Also:
    • createDefaultSkin

      protected Skin<?> createDefaultSkin()
      Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).
      Returns:
      new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.
      Since:
      JavaFX 8.0
    • skinProperty

      public final ObjectProperty<Skin<?>> skinProperty()
      Skin is responsible for rendering this Control. From the perspective of the Control, the Skin is a black box. It listens and responds to changes in state in a Control.

      There is a one-to-one relationship between a Control and its Skin. Every Skin maintains a back reference to the Control via the Skin.getSkinnable() method.

      A skin may be null.

      Specified by:
      skinProperty in interface Skinnable
      Returns:
      the skin property
      See Also:
    • setSkin

      public final void setSkin(Skin<?> value)
      Sets the value of the skin property.
      Specified by:
      setSkin in interface Skinnable
      Property description:
      Skin is responsible for rendering this Control. From the perspective of the Control, the Skin is a black box. It listens and responds to changes in state in a Control.

      There is a one-to-one relationship between a Control and its Skin. Every Skin maintains a back reference to the Control via the Skin.getSkinnable() method.

      A skin may be null.

      Parameters:
      value - the value for the skin property
      See Also:
    • getSkin

      public final Skin<?> getSkin()
      Gets the value of the skin property.
      Specified by:
      getSkin in interface Skinnable
      Property description:
      Skin is responsible for rendering this Control. From the perspective of the Control, the Skin is a black box. It listens and responds to changes in state in a Control.

      There is a one-to-one relationship between a Control and its Skin. Every Skin maintains a back reference to the Control via the Skin.getSkinnable() method.

      A skin may be null.

      Returns:
      the value of the skin property
      See Also:
    • computeMinWidth

      protected double computeMinWidth(double height)
      Computes the minimum allowable width of the Control, based on the provided height. The minimum width is not calculated within the Control, instead the calculation is delegated to the LayoutMeasurableMixin.minWidth(double) method of the Skin. If the Skin is null, the returned value is 0.
      Overrides:
      computeMinWidth in class Region
      Parameters:
      height - The height of the Control, in case this value might dictate the minimum width.
      Returns:
      A double representing the minimum width of this control.
    • computeMinHeight

      protected double computeMinHeight(double width)
      Computes the minimum allowable height of the Control, based on the provided width. The minimum height is not calculated within the Control, instead the calculation is delegated to the LayoutMeasurableMixin.minHeight(double) method of the Skin. If the Skin is null, the returned value is 0.
      Overrides:
      computeMinHeight in class Region
      Parameters:
      width - The width of the Control, in case this value might dictate the minimum height.
      Returns:
      A double representing the minimum height of this control.
    • computeMaxWidth

      protected double computeMaxWidth(double height)
      Computes the maximum allowable width of the Control, based on the provided height. The maximum width is not calculated within the Control, instead the calculation is delegated to the LayoutMeasurableMixin.maxWidth(double) method of the Skin. If the Skin is null, the returned value is 0.
      Overrides:
      computeMaxWidth in class Region
      Parameters:
      height - The height of the Control, in case this value might dictate the maximum width.
      Returns:
      A double representing the maximum width of this control.
    • computeMaxHeight

      protected double computeMaxHeight(double width)
      Computes the maximum allowable height of the Control, based on the provided width. The maximum height is not calculated within the Control, instead the calculation is delegated to the LayoutMeasurableMixin.maxHeight(double) method of the Skin. If the Skin is null, the returned value is 0.
      Overrides:
      computeMaxHeight in class Region
      Parameters:
      width - The width of the Control, in case this value might dictate the maximum height.
      Returns:
      A double representing the maximum height of this control.
    • computePrefWidth

      protected double computePrefWidth(double height)
      Computes the preferred width of this region for the given height. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
      Overrides:
      computePrefWidth in class Region
      Parameters:
      height - the height that should be used if preferred width depends on it
      Returns:
      the computed preferred width for this region
    • computePrefHeight

      protected double computePrefHeight(double width)
      Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
      Overrides:
      computePrefHeight in class Region
      Parameters:
      width - the width that should be used if preferred height depends on it
      Returns:
      the computed preferred height for this region
    • getBaselineOffset

      public double getBaselineOffset()
      Calculates the baseline offset based on the first managed child. If there is no such child, returns INode.getBaselineOffset().
      Specified by:
      getBaselineOffset in interface INode
      Overrides:
      getBaselineOffset in class Parent
      Returns:
      baseline offset
    • layoutChildren

      protected void layoutChildren()
      Invoked during the layout pass to layout the children in this Parent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.

      Subclasses should override this function to layout content as needed.

      Overrides:
      layoutChildren in class Parent
    • shouldUseLayoutMeasurable

      public boolean shouldUseLayoutMeasurable()
      Overrides:
      shouldUseLayoutMeasurable in class Node