Class Button.Builder<B extends Button.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
Accessible.Builder<B>, Actionable.Builder<B>, BuilderInterface
Direct Known Subclasses:
LinkButton.Builder, LockButton.Builder, StyleSchemeChooserButton.Builder, ToggleButton.Builder
Enclosing class:
Button

public static class Button.Builder<B extends Button.Builder<B>> extends Widget.Builder<B> implements Accessible.Builder<B>, Actionable.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public Button build()
      Finish building the Button object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to Button.
      Overrides:
      build in class Widget.Builder<B extends Button.Builder<B>>
      Returns:
      a new instance of Button with the properties that were set in the Builder object.
    • setCanShrink

      public B setCanShrink(boolean canShrink)

      Whether the size of the button can be made smaller than the natural size of its contents.

      For text buttons, setting this property will allow ellipsizing the label.

      If the contents of a button are an icon or a custom widget, setting this property has no effect.

      Parameters:
      canShrink - the value for the can-shrink property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      4.12
    • setChild

      public B setChild(Widget child)
      The child widget.
      Parameters:
      child - the value for the child property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHasFrame

      public B setHasFrame(boolean hasFrame)
      Whether the button has a frame.
      Parameters:
      hasFrame - the value for the has-frame property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setIconName

      public B setIconName(String iconName)
      The name of the icon used to automatically populate the button.
      Parameters:
      iconName - the value for the icon-name property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setLabel

      public B setLabel(String label)
      Text of the label inside the button, if the button contains a label widget.
      Parameters:
      label - the value for the label property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setUseUnderline

      public B setUseUnderline(boolean useUnderline)
      If set, an underline in the text indicates that the following character is to be used as mnemonic.
      Parameters:
      useUnderline - the value for the use-underline property
      Returns:
      the Builder instance is returned, to allow method chaining
    • onActivate

      public B onActivate(Button.ActivateCallback handler)

      Emitted to animate press then release.

      This is an action signal. Applications should never connect to this signal, but use the Gtk.Button::clicked signal.

      The default bindings for this signal are all forms of the and Enter keys.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onClicked

      public B onClicked(Button.ClickedCallback handler)
      Emitted when the button has been activated (pressed and released).
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: