Class ComboBoxText

All Implemented Interfaces:
Accessible, Buildable, CellEditable, CellLayout, ConstraintTarget, Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class ComboBoxText extends ComboBox implements Accessible, Buildable, CellEditable, CellLayout, ConstraintTarget
Deprecated.
Use DropDown with a StringList instead

A GtkComboBoxText is a simple variant of GtkComboBox for text-only use cases.

An example GtkComboBoxText

GtkComboBoxText hides the model-view complexity of GtkComboBox.

To create a GtkComboBoxText, use ComboBoxText() or withEntry().

You can add items to a GtkComboBoxText with appendText(String), insertText(int, String) or prependText(String) and remove options with remove(int).

If the GtkComboBoxText contains an entry (via the Gtk.ComboBox:has-entry property), its contents can be retrieved using getActiveText().

You should not call ComboBox.setModel(TreeModel) or attempt to pack more cells into this combo box via its CellLayout interface.

GtkComboBoxText as GtkBuildable

The GtkComboBoxText implementation of the GtkBuildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element can specify the “id” corresponding to the appended text and also supports the regular translation attributes “translatable”, “context” and “comments”.

Here is a UI definition fragment specifying GtkComboBoxText items:

<object class="GtkComboBoxText">
  <items>
    <item translatable="yes" id="factory">Factory</item>
    <item translatable="yes" id="home">Home</item>
    <item translatable="yes" id="subway">Subway</item>
  </items>
</object>

CSS nodes

combobox
╰── box.linked
    ├── entry.combo
    ├── button.combo
    ╰── window.popup

GtkComboBoxText has a single CSS node with name combobox. It adds the style class .combo to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.

  • Constructor Details

    • ComboBoxText

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

      public ComboBoxText()
      Deprecated.
      Create a new ComboBoxText.
  • Method Details

    • getType

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

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

      protected ComboBoxText asParent()
      Deprecated.
      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 ComboBox
      Returns:
      the instance as if it were its parent type
    • withEntry

      @Deprecated public static ComboBoxText withEntry()
      Deprecated.
      Creates a new GtkComboBoxText with an entry.
      Returns:
      a new GtkComboBoxText
    • append

      @Deprecated public void append(@Nullable String id, String text)
      Deprecated.

      Appends text to the list of strings stored in comboBox.

      If id is non-null then it is used as the ID of the row.

      This is the same as calling insert(int, String, String) with a position of -1.

      Parameters:
      id - a string ID for this value
      text - A string
    • appendText

      @Deprecated public void appendText(String text)
      Deprecated.

      Appends text to the list of strings stored in comboBox.

      This is the same as calling insertText(int, String) with a position of -1.

      Parameters:
      text - A string
    • getActiveText

      @Deprecated public @Nullable String getActiveText()
      Deprecated.

      Returns the currently active string in comboBox.

      If no row is currently selected, null is returned. If this ComboBoxText contains an entry, this function will return its contents (which will not necessarily be an item from the list).

      Returns:
      a newly allocated string containing the currently active text. Must be freed with g_free().
    • insert

      @Deprecated public void insert(int position, @Nullable String id, String text)
      Deprecated.

      Inserts text at position in the list of strings stored in comboBox.

      If id is non-null then it is used as the ID of the row. See Gtk.ComboBox:id-column.

      If position is negative then text is appended.

      Parameters:
      position - An index to insert text
      id - a string ID for this value
      text - A string to display
    • insertText

      @Deprecated public void insertText(int position, String text)
      Deprecated.

      Inserts text at position in the list of strings stored in comboBox.

      If position is negative then text is appended.

      This is the same as calling insert(int, String, String) with a null ID string.

      Parameters:
      position - An index to insert text
      text - A string
    • prepend

      @Deprecated public void prepend(@Nullable String id, String text)
      Deprecated.

      Prepends text to the list of strings stored in comboBox.

      If id is non-null then it is used as the ID of the row.

      This is the same as calling insert(int, String, String) with a position of 0.

      Parameters:
      id - a string ID for this value
      text - a string
    • prependText

      @Deprecated public void prependText(String text)
      Deprecated.

      Prepends text to the list of strings stored in comboBox.

      This is the same as calling insertText(int, String) with a position of 0.

      Parameters:
      text - A string
    • remove

      @Deprecated public void remove(int position)
      Deprecated.
      Removes the string at position from comboBox.
      Parameters:
      position - Index of the item to remove
    • removeAll

      @Deprecated public void removeAll()
      Deprecated.
      Removes all the text entries from the combo box.
    • builder

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