Skip to content

ListHandle

classclient onlysince 0.1.0

com.galdurstudio.galdurui.api.window.ListHandle

Handle to a scrolling list of a GaldurWindow: its lines, the selected line and the scroll position.

Returned by GaldurWindow.addList(...). As with CheckboxHandle, the state lives here, not in the shown widget: it survives resizes, and the lines can change at any time, even while the window is open, without rebuilding the screen.

Example.java
ListHandle ores = window.addList(5);ores.addLine(Component.literal("Iron"));ores.addLine(Component.literal("Gold"));ores.onSelect(index -> System.out.println("Chosen: " + index));

The list width is computed when the screen is built, from the longest line. A longer line added later is clipped at the edge until the next rebuild (resize, or an element added to the window). Like any ElementHandle, the list can be disabled, hidden or given a tooltip.

Call on the client thread.

public class ListHandle extends ElementHandle
PACKAGEapi.window
SIDEclient only

MEMBERS · 15

Methods 15

addLine

public void addLine(Component line)

Adds a line at the end of the list.

PARAMETERS

lineComponentthe line text

setLines

public void setLines(List<Component> newLines)

Replaces all lines, for instance to show a search result. The selection is cleared, since its index would now point at another line; if there was one, onSelect() is called with -1.

PARAMETERS

newLinesList<Component>the new lines, in display order; the list is copied

clearLines

public void clearLines()

Removes all lines, and the selection with them.

getLines

public List<Component> getLines()

RETURNSList<Component> — the lines, read-only; the view follows changes to the list

getSelected

public int getSelected()

RETURNSint — the index of the selected line, or -1 if none

setSelected

public void setSelected(int index)

Selects a line. When the value really changes, the action given to onSelect() is called, whether the change comes from the player or from code.

PARAMETERS

indexintthe line index, or -1 for none; an index outside the list counts as -1

onSelect

public void onSelect(IntConsumer action)

Sets the action called when the selection changes. Only one action is kept: a new call replaces the previous one. It receives the line index, or -1.

PARAMETERS

actionIntConsumercalled on every selection change

getScroll

public double getScroll()

RETURNSdouble — the scroll offset, in pixels from the top of the content

setScroll

public void setScroll(double scroll)

Remembers the scroll offset, to restore it when the screen is rebuilt. Called by the shown widget; a mod usually does not need it.

PARAMETERS

scrolldoubleoffset, in pixels from the top of the content
public void setEnabled(boolean enabled)

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

PARAMETERS

enabledbooleanfalse to disable it
public boolean isEnabled()

RETURNSboolean — 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.

PARAMETERS

visiblebooleanfalse to hide it
public boolean isVisible()

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

public void setTooltip(Component tooltip)

Sets the text shown when the element is hovered.

PARAMETERS

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

RETURNSComponent — the tooltip text, or null if none

© 2026 Galdur Studio · galdurstudio.com · Discord · LGPL-3.0-onlyNot an official Minecraft product. Not approved by or associated with Mojang or Microsoft.