From 67635ab3472a4e23721226513b57a1fa63001b2c Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Wed, 14 Sep 2022 17:25:14 +0300 Subject: WTabPanel: Add method for accessing tab count --- .../java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java index 543758e..dd11eaf 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTabPanel.java @@ -144,7 +144,7 @@ public class WTabPanel extends WPanel { public WTabPanel setSelectedIndex(int tabIndex) { mainPanel.setSelectedIndex(tabIndex); - for (int i = 0; i < tabWidgets.size(); i++) { + for (int i = 0; i < getTabCount(); i++) { tabWidgets.get(i).selected = (i == tabIndex); } @@ -152,6 +152,14 @@ public class WTabPanel extends WPanel { return this; } + /** + * {@return the number of tabs in this tab panel} + * @since 6.3.0 + */ + public int getTabCount() { + return tabWidgets.size(); + } + @Override public void setSize(int x, int y) { super.setSize(x, y); -- cgit