X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWidget.java;h=2ca7108146c0090809d543b91233da31adda130b;hb=2b9c27db318b916730aa04f2b41bd3bff795a5dc;hp=17f7849631f5bd087f536cf48f4068bf211447b7;hpb=30d336cc33e26af877f7950b93f3b77d9c3a3bd3;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 17f7849..2ca7108 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -48,7 +48,7 @@ import static jexer.TKeypress.*; * TWidget is the base class of all objects that can be drawn on screen or * handle user input events. */ -public abstract class TWidget { +public abstract class TWidget implements Comparable { /** * Every widget has a parent widget that it may be "contained" in. For @@ -332,12 +332,19 @@ public abstract class TWidget { private int cursorY = 0; /** - * Comparison operator sorts on tabOrder. + * Comparison operator sorts on tabOrder for TWidgets and z for TWindows. * - * @param that another TWidget instance - * @return difference between this.tabOrder and that.tabOrder + * @param that another TWidget or TWindow instance + * @return difference between this.tabOrder and that.tabOrder, or + * difference between this.z and that.z */ - public final int compare(final TWidget that) { + @Override + public final int compareTo(final TWidget that) { + if ((this instanceof TWindow) + && (that instanceof TWindow) + ) { + return (((TWindow) this).getZ() - ((TWindow) that).getZ()); + } return (this.tabOrder - that.tabOrder); }