X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWindow.java;fp=src%2Fjexer%2FTWindow.java;h=962130560af8c7ed9cd3f9367db389c7b7bbc9a4;hb=71a389c9810382e014682dde52e94d3f34e385fa;hp=32907a8a9c9046ec4329182623b0137c72391086;hpb=e8a11f986bfe2556e450d7b8ad6ef0059b369bbc;p=fanfix.git diff --git a/src/jexer/TWindow.java b/src/jexer/TWindow.java index 32907a8..9621305 100644 --- a/src/jexer/TWindow.java +++ b/src/jexer/TWindow.java @@ -284,9 +284,60 @@ public class TWindow extends TWidget { * @param maximumWindowWidth new maximum width */ public final void setMaximumWindowWidth(final int maximumWindowWidth) { + if ((maximumWindowWidth != -1) + && (maximumWindowWidth < minimumWindowWidth + 1) + ) { + throw new IllegalArgumentException("Maximum window width cannot " + + "be smaller than minimum window width + 1"); + } this.maximumWindowWidth = maximumWindowWidth; } + /** + * Set the minimum width for this window. + * + * @param minimumWindowWidth new minimum width + */ + public final void setMinimumWindowWidth(final int minimumWindowWidth) { + if ((maximumWindowWidth != -1) + && (minimumWindowWidth > maximumWindowWidth - 1) + ) { + throw new IllegalArgumentException("Minimum window width cannot " + + "be larger than maximum window width - 1"); + } + this.minimumWindowWidth = minimumWindowWidth; + } + + /** + * Set the maximum height for this window. + * + * @param maximumWindowHeight new maximum height + */ + public final void setMaximumWindowHeight(final int maximumWindowHeight) { + if ((maximumWindowHeight != -1) + && (maximumWindowHeight < minimumWindowHeight + 1) + ) { + throw new IllegalArgumentException("Maximum window height cannot " + + "be smaller than minimum window height + 1"); + } + this.maximumWindowHeight = maximumWindowHeight; + } + + /** + * Set the minimum height for this window. + * + * @param minimumWindowHeight new minimum height + */ + public final void setMinimumWindowHeight(final int minimumWindowHeight) { + if ((maximumWindowHeight != -1) + && (minimumWindowHeight > maximumWindowHeight - 1) + ) { + throw new IllegalArgumentException("Minimum window height cannot " + + "be larger than maximum window height - 1"); + } + this.minimumWindowHeight = minimumWindowHeight; + } + /** * Recenter the window on-screen. */