From 1c19fdeaff911aa6e9e028f3ad4db06c8d0597dd Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Sun, 20 Aug 2017 16:44:35 -0400 Subject: [PATCH] Fix ClassCastException --- src/jexer/TApplication.java | 4 ++++ src/jexer/TWidget.java | 14 ++++++++++++-- src/jexer/menu/TMenu.java | 7 +++++++ src/jexer/menu/TMenu.properties | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 57d6095..66f7110 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -2512,6 +2512,10 @@ public class TApplication implements Runnable { showAboutDialog(); return true; } + if (menu.getId() == TMenu.MID_REPAINT) { + doRepaint(); + return true; + } return false; } diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 22766dd..12e4344 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -622,7 +622,12 @@ public abstract class TWidget implements Comparable { this.parent = parent; this.window = parent.window; children = new ArrayList(); - parent.addChild(this); + + // Do not add TStatusBars, they are drawn by TApplication + if (this instanceof TStatusBar) { + } else { + parent.addChild(this); + } } /** @@ -642,7 +647,12 @@ public abstract class TWidget implements Comparable { this.parent = parent; this.window = parent.window; children = new ArrayList(); - parent.addChild(this); + + // Do not add TStatusBars, they are drawn by TApplication + if (this instanceof TStatusBar) { + } else { + parent.addChild(this); + } this.x = x; this.y = y; diff --git a/src/jexer/menu/TMenu.java b/src/jexer/menu/TMenu.java index 0e948ce..c4a11df 100644 --- a/src/jexer/menu/TMenu.java +++ b/src/jexer/menu/TMenu.java @@ -104,6 +104,9 @@ public final class TMenu extends TWindow { public static final int MID_HELP_ACTIVE_FILE = 45; public static final int MID_ABOUT = 46; + // Other + public static final int MID_REPAINT = 50; + /** * Public constructor. * @@ -477,6 +480,10 @@ public final class TMenu extends TWindow { label = i18n.getString("menuHelpAbout"); break; + case MID_REPAINT: + label = i18n.getString("menuRepaintDesktop"); + break; + default: throw new IllegalArgumentException("Invalid menu ID: " + id); } diff --git a/src/jexer/menu/TMenu.properties b/src/jexer/menu/TMenu.properties index bf3b4f3..000df91 100644 --- a/src/jexer/menu/TMenu.properties +++ b/src/jexer/menu/TMenu.properties @@ -20,3 +20,5 @@ menuHelpPrevious=&Previous topic menuHelpHelp=&Help on help menuHelpActive=Active &file... menuHelpAbout=&About... + +menuRepaintDesktop=&Repaint desktop -- 2.27.0