From 9dac7f4cbd21987727813ff23612729e84796520 Mon Sep 17 00:00:00 2001 From: Aya <31237389+tal5@users.noreply.github.com> Date: Mon, 13 Nov 2023 22:19:18 +0000 Subject: Add scroll bar getters and setters to WScrollPanel (#225) --- .../cottonmc/cotton/gui/widget/WScrollPanel.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java index 620adc8..d0582af 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollPanel.java @@ -9,6 +9,8 @@ import io.github.cottonmc.cotton.gui.GuiDescription; import io.github.cottonmc.cotton.gui.widget.data.Axis; import io.github.cottonmc.cotton.gui.widget.data.InputResult; +import java.util.Objects; + /** * Similar to the JScrollPane in Swing, this widget represents a scrollable widget. * @@ -50,6 +52,27 @@ public class WScrollPanel extends WClippedPanel { children.add(verticalScrollBar); // Only vertical scroll bar } + /** + * Returns this scroll panel's horizontal scroll bar. + * + * @return the horizontal scroll bar + */ + public WScrollBar getHorizontalScrollBar() { + return this.horizontalScrollBar; + } + + /** + * Sets this scroll panel's horizontal scroll bar. + * + * @param horizontalScrollBar the new horizontal scroll bar + * @return this scroll panel + * @throws NullPointerException if the horizontalScrollBar is null + */ + public WScrollPanel setHorizontalScrollBar(WScrollBar horizontalScrollBar) { + this.horizontalScrollBar = Objects.requireNonNull(horizontalScrollBar, "horizontalScrollBar"); + return this; + } + /** * Returns whether this scroll panel has a horizontal scroll bar. * @@ -70,6 +93,27 @@ public class WScrollPanel extends WClippedPanel { return this; } + /** + * Returns this scroll panel's vertical scroll bar. + * + * @return the vertical scroll bar + */ + public WScrollBar getVerticalScrollBar() { + return this.verticalScrollBar; + } + + /** + * Sets this scroll panel's vertical scroll bar. + * + * @param verticalScrollBar the new vertical scroll bar + * @return this scroll panel + * @throws NullPointerException if the verticalScrollBar is null + */ + public WScrollPanel setVerticalScrollBar(WScrollBar verticalScrollBar) { + this.verticalScrollBar = Objects.requireNonNull(verticalScrollBar, "verticalScrollBar"); + return this; + } + /** * Returns whether this scroll panel has a vertical scroll bar. * -- cgit