Class Frame

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy

@Generated("org.javagi.JavaGI") public class Frame extends Widget implements Accessible, Buildable, ConstraintTarget

Surrounds its child with a decorative frame and an optional label.

An example GtkFrame

If present, the label is drawn inside the top edge of the frame. The horizontal position of the label can be controlled with setLabelAlign(float).

GtkFrame clips its child. You can use this to add rounded corners to widgets, but be aware that it also cuts off shadows.

GtkFrame as GtkBuildable

An example of a UI definition fragment with GtkFrame:

<object class="GtkFrame">
  <property name="label-widget">
    <object class="GtkLabel" id="frame_label"/>
  </property>
  <property name="child">
    <object class="GtkEntry" id="frame_content"/>
  </property>
</object>

CSS nodes

frame
├── <label widget>
╰── <child>

GtkFrame has a main CSS node with name “frame”, which is used to draw the visible border. You can set the appearance of the border using CSS properties like “border-style” on this node.

Accessibility

GtkFrame uses the Gtk.AccessibleRole.group role.

  • Constructor Details

    • Frame

      public Frame(MemorySegment address)
      Create a Frame instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Frame

      public Frame(@Nullable String label)

      Creates a new GtkFrame, with optional label label.

      If label is null, the label is omitted.

      Parameters:
      label - the text to use as the label of the frame
    • Frame

      public Frame()
      Create a new Frame.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Frame class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Frame asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Widget
      Returns:
      the instance as if it were its parent type
    • getChild

      public @Nullable Widget getChild()
      Gets the child widget of frame.
      Returns:
      the child widget of this Frame
    • getLabel

      public @Nullable String getLabel()

      Returns the frame labels text.

      If the frame's label widget is not a GtkLabel, null is returned.

      Returns:
      the text in the label, or null if there was no label widget or the label widget was not a GtkLabel. This string is owned by GTK and must not be modified or freed.
    • getLabelAlign

      public float getLabelAlign()
      Retrieves the X alignment of the frame’s label.
      Returns:
      the frames X alignment
    • getLabelWidget

      public @Nullable Widget getLabelWidget()
      Retrieves the label widget for the frame.
      Returns:
      the label widget
    • setChild

      public void setChild(@Nullable Widget child)
      Sets the child widget of frame.
      Parameters:
      child - the child widget
    • setLabel

      public void setLabel(@Nullable String label)
      Creates a new GtkLabel with the label and sets it as the frame's label widget.
      Parameters:
      label - the text to use as the label of the frame
    • setLabelAlign

      public void setLabelAlign(float xalign)

      Sets the X alignment of the frame widget’s label.

      The default value for a newly created frame is 0.0.

      Parameters:
      xalign - The position of the label along the top edge of the widget. A value of 0.0 represents left alignment; 1.0 represents right alignment.
    • setLabelWidget

      public void setLabelWidget(@Nullable Widget labelWidget)

      Sets the label widget for the frame.

      This is the widget that will appear embedded in the top edge of the frame as a title.

      Parameters:
      labelWidget - the new label widget
    • computeChildAllocation

      protected void computeChildAllocation(Allocation allocation)
    • builder

      public static Frame.Builder<? extends Frame.Builder> builder()
      A Frame.Builder object constructs a Frame with the specified properties. Use the various set...() methods to set properties, and finish construction with Frame.Builder.build().
      Returns:
      the builder object