Class SwingUtils
java.lang.Object
uno.anahata.ai.swing.util.SwingUtils
General Swing utility methods.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA generic data class to hold the state of a scroll pane's viewport, anchored to a stable model object. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SwingUtils.ScrollState<T> getScrollState(JScrollPane scrollPane, Function<Component, T> anchorExtractor) Captures the precise scroll state of a JScrollPane.
-
Method Details
-
getScrollState
public static <T> SwingUtils.ScrollState<T> getScrollState(JScrollPane scrollPane, Function<Component, T> anchorExtractor) Captures the precise scroll state of a JScrollPane. It identifies the component closest to the center of the viewport as the user's focus, extracts a stable anchor object from it using the provided function, and records the precise pixel offset.- Type Parameters:
T- The type of the anchor object.- Parameters:
scrollPane- The JScrollPane to inspect.anchorExtractor- A function that takes a Component and returns a stable, non-UI anchor object (e.g., a data model object).- Returns:
- A
SwingUtils.ScrollStateobject, ornullif the state could not be determined.
-
