Aller au contenu
galdurdocs

TabsHandle

classclient uniquementdepuis 0.1.0

com.galdurstudio.galdurui.api.window.TabsHandle

Pas encore traduit : texte d’origine en anglais.

Handle to a tab row of a GaldurWindow: its tabs and the active tab.

Returned by GaldurWindow.addTabs(). Each addTab() returns a TabHandle, filled like a window. The first tab added starts active.

Example.java
TabsHandle tabs = window.addTabs(true);TabHandle storage = tabs.addTab(Component.literal("Storage"));TabHandle autocraft = tabs.addTab(Component.literal("Autocraft"));tabs.onSelect(index -> System.out.println("Tab: " + index));autocraft.select();   // or tabs.setSelected(1)

As with ListHandle, the state lives here, not in the shown widget: the active tab survives resizes, and each tab's content (search text, list scroll...) is kept when switching tabs.

Like any ElementHandle, the row can be disabled, hidden or given a tooltip:

  • disabled, tabs can no longer be switched, and the shown content is disabled too;
  • hidden, it disappears with all its content and frees its space;
  • its tooltip shows only when the tab row is hovered, not on the content.

Call on the client thread.

public class TabsHandle extends ElementHandle
PAQUETapi.window
CÔTÉclient uniquement
HÉRITE DEElementHandle

MEMBRES · 11

Méthodes 11

addTab

public TabHandle addTab(Component title)

Adds a tab to the right of the others and returns its handle, used to fill its content.

PARAMÈTRES

titleComponentthe title shown on the tab

RENVOIETabHandle — the tab handle

getTabs

public List<TabHandle> getTabs()

RENVOIEList<TabHandle> — the tabs, in order, read-only; the view follows additions

getSelected

public int getSelected()

RENVOIEint — the index of the active tab, or -1 if there is no tab yet

setSelected

public void setSelected(int index)

Makes a tab active. When the value really changes, its content replaces the old one on the next frame and the action given to onSelect() is called, whether the change comes from the player or from code.

PARAMÈTRES

indexintthe tab index; an index outside the tabs is ignored

onSelect

public void onSelect(IntConsumer action)

Sets the action called when the active tab changes. Only one action is kept: a new call replaces the previous one. It receives the index of the new active tab.

PARAMÈTRES

actionIntConsumercalled on every tab change
public void setEnabled(boolean enabled)

Enables or disables the element. No effect if it is already in that state.

PARAMÈTRES

enabledbooleanfalse to disable it
public boolean isEnabled()

RENVOIEboolean — true if the element is enabled (the default)

public void setVisible(boolean visible)

Shows or hides the element. Hidden, it frees its space in the window. No effect if it is already in that state.

PARAMÈTRES

visiblebooleanfalse to hide it
public boolean isVisible()

RENVOIEboolean — true if the element is shown (the default)

public void setTooltip(Component tooltip)

Sets the text shown when the element is hovered.

PARAMÈTRES

tooltipComponentthe tooltip text, or null to remove it
public Component getTooltip()

RENVOIEComponent — the tooltip text, or null if none

© 2026 Galdur Studio · galdurstudio.com · Discord · LGPL-3.0-onlyProduit non officiel. Non approuvé par Mojang ou Microsoft, ni associé à eux.