From 5d26b50423486b1e680e3adfc0054f6fd0bbcefe Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Thu, 1 Aug 2019 16:35:25 -0500 Subject: [PATCH] #41 be explicit that height/width cannot be negative --- src/jexer/TWidget.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index c9e0ded..8a49c81 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -204,6 +204,13 @@ public abstract class TWidget implements Comparable { protected TWidget(final TWidget parent, final boolean enabled, final int x, final int y, final int width, final int height) { + if (width < 0) { + throw new IllegalArgumentException("width cannot be negative"); + } + if (height < 0) { + throw new IllegalArgumentException("height cannot be negative"); + } + this.enabled = enabled; this.parent = parent; this.window = parent.window; @@ -234,6 +241,13 @@ public abstract class TWidget implements Comparable { protected final void setupForTWindow(final TWindow window, final int x, final int y, final int width, final int height) { + if (width < 0) { + throw new IllegalArgumentException("width cannot be negative"); + } + if (height < 0) { + throw new IllegalArgumentException("height cannot be negative"); + } + this.parent = window; this.window = window; this.x = x; -- 2.27.0