From 43ad7b6c509c45c8f261e77ea059c10fed8c9f1c Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Sun, 3 Dec 2017 18:35:06 -0500 Subject: [PATCH 1/1] More PMD warnings --- src/jexer/TApplication.java | 5 + src/jexer/TDesktop.java | 2 +- src/jexer/TFileOpenBox.java | 1 - src/jexer/TInputBox.java | 1 - src/jexer/TMessageBox.java | 1 - src/jexer/bits/MnemonicString.java | 10 +- src/jexer/demos/Demo1.java | 1 + src/jexer/demos/Demo5.java | 12 ++ src/jexer/demos/DemoApplication.java | 113 ++++++++++--------- src/jexer/demos/DemoCheckboxWindow.java | 4 + src/jexer/demos/DemoEditorWindow.java | 12 ++ src/jexer/demos/DemoMainWindow.java | 51 ++++++--- src/jexer/demos/DemoMsgBoxWindow.java | 4 + src/jexer/demos/DemoTextFieldWindow.java | 5 + src/jexer/demos/DemoTextWindow.java | 12 ++ src/jexer/demos/DemoTreeViewWindow.java | 12 ++ src/jexer/demos/DesktopDemo.java | 30 +++-- src/jexer/demos/DesktopDemoApplication.java | 117 +++++++++++--------- src/jexer/menu/TMenu.java | 6 +- src/jexer/menu/TSubMenu.java | 4 +- src/jexer/package-info.java | 1 - 21 files changed, 264 insertions(+), 140 deletions(-) diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 6dd503f..f802e2b 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -2947,6 +2947,7 @@ public class TApplication implements Runnable { * @param title window title, will be centered along the top border * @param width width of window * @param height height of window + * @return the new window */ public final TWindow addWindow(final String title, final int width, final int height) { @@ -2963,6 +2964,7 @@ public class TApplication implements Runnable { * @param width width of window * @param height height of window * @param flags bitmask of RESIZABLE, CENTERED, or MODAL + * @return the new window */ public final TWindow addWindow(final String title, final int width, final int height, final int flags) { @@ -2979,6 +2981,7 @@ public class TApplication implements Runnable { * @param y row relative to parent * @param width width of window * @param height height of window + * @return the new window */ public final TWindow addWindow(final String title, final int x, final int y, final int width, final int height) { @@ -2996,6 +2999,7 @@ public class TApplication implements Runnable { * @param width width of window * @param height height of window * @param flags mask of RESIZABLE, CENTERED, or MODAL + * @return the new window */ public final TWindow addWindow(final String title, final int x, final int y, final int width, final int height, @@ -3010,6 +3014,7 @@ public class TApplication implements Runnable { * active. * * @param file the file to open + * @return the new editor window * @throws IOException if a java.io operation throws */ public final TEditorWindow addEditor(final File file) throws IOException { diff --git a/src/jexer/TDesktop.java b/src/jexer/TDesktop.java index 1074272..1167e0c 100644 --- a/src/jexer/TDesktop.java +++ b/src/jexer/TDesktop.java @@ -47,7 +47,7 @@ import jexer.event.TMouseEvent; *
  • Keypress events are seen if no other windows are open.
  • *
  • Menu events are seen if no other windows are open.
  • *
  • Command events are seen if no other windows are open.
  • - * */ public class TDesktop extends TWindow { diff --git a/src/jexer/TFileOpenBox.java b/src/jexer/TFileOpenBox.java index 18d65f2..094f8fa 100644 --- a/src/jexer/TFileOpenBox.java +++ b/src/jexer/TFileOpenBox.java @@ -43,7 +43,6 @@ import static jexer.TKeypress.*; * TFileOpenBox is a system-modal dialog for selecting a file to open. Call * it like: * - *

    *

      * {@code
      *     filename = application.fileOpenBox("/path/to/file.ext",
    diff --git a/src/jexer/TInputBox.java b/src/jexer/TInputBox.java
    index bf54f1c..50dba36 100644
    --- a/src/jexer/TInputBox.java
    +++ b/src/jexer/TInputBox.java
    @@ -32,7 +32,6 @@ package jexer;
      * TInputBox is a system-modal dialog with an OK button and a text input
      * field.  Call it like:
      *
    - * 

    *

      * {@code
      *     box = application.inputBox(title, caption);
    diff --git a/src/jexer/TMessageBox.java b/src/jexer/TMessageBox.java
    index cd4a514..0e5cf7d 100644
    --- a/src/jexer/TMessageBox.java
    +++ b/src/jexer/TMessageBox.java
    @@ -39,7 +39,6 @@ import static jexer.TKeypress.*;
      * TMessageBox is a system-modal dialog with buttons for OK, Cancel, Yes, or
      * No.  Call it like:
      *
    - * 

    *

      * {@code
      *     box = application.messageBox(title, caption,
    diff --git a/src/jexer/bits/MnemonicString.java b/src/jexer/bits/MnemonicString.java
    index edd5227..d0032b6 100644
    --- a/src/jexer/bits/MnemonicString.java
    +++ b/src/jexer/bits/MnemonicString.java
    @@ -29,10 +29,10 @@
     package jexer.bits;
     
     /**
    - * MnemonicString is used to render a string like "&File" into a highlighted
    - * 'F' and the rest of 'ile'.  To insert a literal '&', use two '&&'
    - * characters, e.g. "&File && Stuff" would be "File & Stuff" with the first
    - * 'F' highlighted.
    + * MnemonicString is used to render a string like "&File" into a
    + * highlighted 'F' and the rest of 'ile'.  To insert a literal '&', use
    + * two '&&' characters, e.g. "&File && Stuff" would be
    + * "File & Stuff" with the first 'F' highlighted.
      */
     public final class MnemonicString {
     
    @@ -63,7 +63,7 @@ public final class MnemonicString {
          * Public constructor.
          *
          * @param label widget label or title.  Label must contain a keyboard
    -     * shortcut, denoted by prefixing a letter with "&", e.g. "&File"
    +     * shortcut, denoted by prefixing a letter with "&", e.g. "&File"
          */
         public MnemonicString(final String label) {
     
    diff --git a/src/jexer/demos/Demo1.java b/src/jexer/demos/Demo1.java
    index 4715d79..d82a385 100644
    --- a/src/jexer/demos/Demo1.java
    +++ b/src/jexer/demos/Demo1.java
    @@ -35,6 +35,7 @@ import jexer.TApplication;
      * capabilities.
      */
     public class Demo1 {
    +
         /**
          * Main entry point.
          *
    diff --git a/src/jexer/demos/Demo5.java b/src/jexer/demos/Demo5.java
    index df8075a..d383261 100644
    --- a/src/jexer/demos/Demo5.java
    +++ b/src/jexer/demos/Demo5.java
    @@ -44,6 +44,10 @@ import jexer.backend.SwingBackend;
      */
     public class Demo5 implements WindowListener {
     
    +    // ------------------------------------------------------------------------
    +    // Variables --------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * The first demo application instance.
          */
    @@ -54,6 +58,10 @@ public class Demo5 implements WindowListener {
          */
         DemoApplication app2 = null;
     
    +    // ------------------------------------------------------------------------
    +    // WindowListener ---------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Pass window events into the event queue.
          *
    @@ -122,6 +130,10 @@ public class Demo5 implements WindowListener {
             // Ignore
         }
     
    +    // ------------------------------------------------------------------------
    +    // Demo5 ------------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +    
         /**
          * Run two demo applications in separate panes.
          */
    diff --git a/src/jexer/demos/DemoApplication.java b/src/jexer/demos/DemoApplication.java
    index 5036dd0..a9b3468 100644
    --- a/src/jexer/demos/DemoApplication.java
    +++ b/src/jexer/demos/DemoApplication.java
    @@ -41,48 +41,9 @@ import jexer.backend.SwingTerminal;
      */
     public class DemoApplication extends TApplication {
     
    -    /**
    -     * Add all the widgets of the demo.
    -     */
    -    private void addAllWidgets() {
    -        new DemoMainWindow(this);
    -
    -        // Add the menus
    -        addFileMenu();
    -        addEditMenu();
    -
    -        TMenu demoMenu = addMenu("&Demo");
    -        TMenuItem item = demoMenu.addItem(2000, "&Checkable");
    -        item.setCheckable(true);
    -        item = demoMenu.addItem(2001, "Disabled");
    -        item.setEnabled(false);
    -        item = demoMenu.addItem(2002, "&Normal");
    -        TSubMenu subMenu = demoMenu.addSubMenu("Sub-&Menu");
    -        item = demoMenu.addItem(2010, "N&ormal A&&D");
    -        item = demoMenu.addItem(2050, "Co&lors...");
    -
    -        item = subMenu.addItem(2000, "&Checkable (sub)");
    -        item.setCheckable(true);
    -        item = subMenu.addItem(2001, "Disabled (sub)");
    -        item.setEnabled(false);
    -        item = subMenu.addItem(2002, "&Normal (sub)");
    -
    -        subMenu = subMenu.addSubMenu("Sub-&Menu");
    -        item = subMenu.addItem(2000, "&Checkable (sub)");
    -        item.setCheckable(true);
    -        item = subMenu.addItem(2001, "Disabled (sub)");
    -        item.setEnabled(false);
    -        item = subMenu.addItem(2002, "&Normal (sub)");
    -
    -        if (getScreen() instanceof SwingTerminal) {
    -            TMenu swingMenu = addMenu("Swin&g");
    -            item = swingMenu.addItem(3000, "&Bigger +2");
    -            item = swingMenu.addItem(3001, "&Smaller -2");
    -        }
    -
    -        addWindowMenu();
    -        addHelpMenu();
    -    }
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
     
         /**
          * Public constructor.
    @@ -151,6 +112,22 @@ public class DemoApplication extends TApplication {
             addAllWidgets();
         }
     
    +    /**
    +     * Public constructor.
    +     *
    +     * @param backendType one of the TApplication.BackendType values
    +     * @throws Exception if TApplication can't instantiate the Backend.
    +     */
    +    public DemoApplication(final BackendType backendType) throws Exception {
    +        super(backendType);
    +        addAllWidgets();
    +        getBackend().setTitle("Jexer Demo Application");
    +    }
    +
    +    // ------------------------------------------------------------------------
    +    // TApplication -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Handle menu events.
          *
    @@ -199,15 +176,51 @@ public class DemoApplication extends TApplication {
             return super.onMenu(menu);
         }
     
    +    // ------------------------------------------------------------------------
    +    // DemoApplication --------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
    -     * Public constructor.
    -     *
    -     * @param backendType one of the TApplication.BackendType values
    -     * @throws Exception if TApplication can't instantiate the Backend.
    +     * Add all the widgets of the demo.
          */
    -    public DemoApplication(final BackendType backendType) throws Exception {
    -        super(backendType);
    -        addAllWidgets();
    -        getBackend().setTitle("Jexer Demo Application");
    +    private void addAllWidgets() {
    +        new DemoMainWindow(this);
    +
    +        // Add the menus
    +        addFileMenu();
    +        addEditMenu();
    +
    +        TMenu demoMenu = addMenu("&Demo");
    +        TMenuItem item = demoMenu.addItem(2000, "&Checkable");
    +        item.setCheckable(true);
    +        item = demoMenu.addItem(2001, "Disabled");
    +        item.setEnabled(false);
    +        item = demoMenu.addItem(2002, "&Normal");
    +        TSubMenu subMenu = demoMenu.addSubMenu("Sub-&Menu");
    +        item = demoMenu.addItem(2010, "N&ormal A&&D");
    +        item = demoMenu.addItem(2050, "Co&lors...");
    +
    +        item = subMenu.addItem(2000, "&Checkable (sub)");
    +        item.setCheckable(true);
    +        item = subMenu.addItem(2001, "Disabled (sub)");
    +        item.setEnabled(false);
    +        item = subMenu.addItem(2002, "&Normal (sub)");
    +
    +        subMenu = subMenu.addSubMenu("Sub-&Menu");
    +        item = subMenu.addItem(2000, "&Checkable (sub)");
    +        item.setCheckable(true);
    +        item = subMenu.addItem(2001, "Disabled (sub)");
    +        item.setEnabled(false);
    +        item = subMenu.addItem(2002, "&Normal (sub)");
    +
    +        if (getScreen() instanceof SwingTerminal) {
    +            TMenu swingMenu = addMenu("Swin&g");
    +            item = swingMenu.addItem(3000, "&Bigger +2");
    +            item = swingMenu.addItem(3001, "&Smaller -2");
    +        }
    +
    +        addWindowMenu();
    +        addHelpMenu();
         }
    +
     }
    diff --git a/src/jexer/demos/DemoCheckboxWindow.java b/src/jexer/demos/DemoCheckboxWindow.java
    index be0c81f..2e45117 100644
    --- a/src/jexer/demos/DemoCheckboxWindow.java
    +++ b/src/jexer/demos/DemoCheckboxWindow.java
    @@ -38,6 +38,10 @@ import static jexer.TKeypress.*;
      */
     public class DemoCheckboxWindow extends TWindow {
     
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Constructor.
          *
    diff --git a/src/jexer/demos/DemoEditorWindow.java b/src/jexer/demos/DemoEditorWindow.java
    index 0053831..1047159 100644
    --- a/src/jexer/demos/DemoEditorWindow.java
    +++ b/src/jexer/demos/DemoEditorWindow.java
    @@ -38,11 +38,19 @@ import static jexer.TKeypress.*;
      */
     public class DemoEditorWindow extends TWindow {
     
    +    // ------------------------------------------------------------------------
    +    // Variables --------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Hang onto my TEditor so I can resize it with the window.
          */
         private TEditorWidget editField;
     
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Public constructor makes a text window out of any string.
          *
    @@ -99,6 +107,10 @@ public class DemoEditorWindow extends TWindow {
     
         }
     
    +    // ------------------------------------------------------------------------
    +    // TWindow ----------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Handle window/screen resize events.
          *
    diff --git a/src/jexer/demos/DemoMainWindow.java b/src/jexer/demos/DemoMainWindow.java
    index 209bd13..eef25e2 100644
    --- a/src/jexer/demos/DemoMainWindow.java
    +++ b/src/jexer/demos/DemoMainWindow.java
    @@ -41,21 +41,35 @@ import static jexer.TKeypress.*;
      */
     public class DemoMainWindow extends TWindow {
     
    -    // Timer that increments a number.
    +    // ------------------------------------------------------------------------
    +    // Variables --------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
    +    /**
    +     * Timer that increments a number.
    +     */
         private TTimer timer;
     
    -    // Timer label is updated with timer ticks.
    +    /**
    +     * Timer label is updated with timer ticks.
    +     */
         TLabel timerLabel;
     
         /**
    -     * We need to override onClose so that the timer will no longer be called
    -     * after we close the window.  TTimers currently are completely unaware
    -     * of the rest of the UI classes.
    +     * Timer increment used by the timer loop.  Has to be at class scope so
    +     * that it can be accessed by the anonymous TAction class.
          */
    -    @Override
    -    public void onClose() {
    -        getApplication().removeTimer(timer);
    -    }
    +    int timerI = 0;
    +
    +    /**
    +     * Progress bar used by the timer loop.  Has to be at class scope so that
    +     * it can be accessed by the anonymous TAction class.
    +     */
    +    TProgressBar progressBar;
    +
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
     
         /**
          * Construct demo window.  It will be centered on screen.
    @@ -66,11 +80,6 @@ public class DemoMainWindow extends TWindow {
             this(parent, CENTERED | RESIZABLE);
         }
     
    -    // These are used by the timer loop.  They have to be at class scope so
    -    // that they can be accessed by the anonymous TAction class.
    -    int timerI = 0;
    -    TProgressBar progressBar;
    -
         /**
          * Constructor.
          *
    @@ -212,6 +221,20 @@ public class DemoMainWindow extends TWindow {
             statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
         }
     
    +    // ------------------------------------------------------------------------
    +    // TWindow ----------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
    +    /**
    +     * We need to override onClose so that the timer will no longer be called
    +     * after we close the window.  TTimers currently are completely unaware
    +     * of the rest of the UI classes.
    +     */
    +    @Override
    +    public void onClose() {
    +        getApplication().removeTimer(timer);
    +    }
    +
         /**
          * Method that subclasses can override to handle posted command events.
          *
    diff --git a/src/jexer/demos/DemoMsgBoxWindow.java b/src/jexer/demos/DemoMsgBoxWindow.java
    index 9a46c7b..27ee790 100644
    --- a/src/jexer/demos/DemoMsgBoxWindow.java
    +++ b/src/jexer/demos/DemoMsgBoxWindow.java
    @@ -37,6 +37,10 @@ import static jexer.TKeypress.*;
      */
     public class DemoMsgBoxWindow extends TWindow {
     
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Constructor.
          *
    diff --git a/src/jexer/demos/DemoTextFieldWindow.java b/src/jexer/demos/DemoTextFieldWindow.java
    index 51656ba..2d9c504 100644
    --- a/src/jexer/demos/DemoTextFieldWindow.java
    +++ b/src/jexer/demos/DemoTextFieldWindow.java
    @@ -37,6 +37,10 @@ import static jexer.TKeypress.*;
      */
     public class DemoTextFieldWindow extends TWindow {
     
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Constructor.
          *
    @@ -88,4 +92,5 @@ public class DemoTextFieldWindow extends TWindow {
             statusBar.addShortcutKeypress(kbF3, cmOpen, "Open");
             statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
         }
    +
     }
    diff --git a/src/jexer/demos/DemoTextWindow.java b/src/jexer/demos/DemoTextWindow.java
    index 3538905..969ca63 100644
    --- a/src/jexer/demos/DemoTextWindow.java
    +++ b/src/jexer/demos/DemoTextWindow.java
    @@ -39,11 +39,19 @@ import static jexer.TKeypress.*;
      */
     public class DemoTextWindow extends TWindow {
     
    +    // ------------------------------------------------------------------------
    +    // Variables --------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Hang onto my TText so I can resize it with the window.
          */
         private TText textField;
     
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Public constructor makes a text window out of any string.
          *
    @@ -111,6 +119,10 @@ public class DemoTextWindow extends TWindow {
     
         }
     
    +    // ------------------------------------------------------------------------
    +    // TWindow ----------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Handle window/screen resize events.
          *
    diff --git a/src/jexer/demos/DemoTreeViewWindow.java b/src/jexer/demos/DemoTreeViewWindow.java
    index a4bcbe2..e31ef76 100644
    --- a/src/jexer/demos/DemoTreeViewWindow.java
    +++ b/src/jexer/demos/DemoTreeViewWindow.java
    @@ -41,11 +41,19 @@ import static jexer.TKeypress.*;
      */
     public class DemoTreeViewWindow extends TWindow {
     
    +    // ------------------------------------------------------------------------
    +    // Variables --------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Hang onto my TTreeView so I can resize it with the window.
          */
         private TTreeViewWidget treeView;
     
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Public constructor.
          *
    @@ -66,6 +74,10 @@ public class DemoTreeViewWindow extends TWindow {
             statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
         }
     
    +    // ------------------------------------------------------------------------
    +    // TWindow ----------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Handle window/screen resize events.
          *
    diff --git a/src/jexer/demos/DesktopDemo.java b/src/jexer/demos/DesktopDemo.java
    index 58d9893..93e8597 100644
    --- a/src/jexer/demos/DesktopDemo.java
    +++ b/src/jexer/demos/DesktopDemo.java
    @@ -36,11 +36,32 @@ import jexer.*;
      */
     public class DesktopDemo extends TDesktop {
     
    +    // ------------------------------------------------------------------------
    +    // Variables --------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * If true, draw the hatch.  Note package private access.
          */
         boolean drawHatch = true;
     
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
    +    /**
    +     * Public constructor.
    +     *
    +     * @param parent parent application
    +     */
    +    public DesktopDemo(final TApplication parent) {
    +        super(parent);
    +    }
    +
    +    // ------------------------------------------------------------------------
    +    // TDesktop ---------------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * The default TDesktop draws a hatch character across everything.  This
          * version is selectable.
    @@ -52,13 +73,4 @@ public class DesktopDemo extends TDesktop {
             }
         }
     
    -    /**
    -     * Public constructor.
    -     *
    -     * @param parent parent application
    -     */
    -    public DesktopDemo(final TApplication parent) {
    -        super(parent);
    -    }
    -
     }
    diff --git a/src/jexer/demos/DesktopDemoApplication.java b/src/jexer/demos/DesktopDemoApplication.java
    index c546aac..0393860 100644
    --- a/src/jexer/demos/DesktopDemoApplication.java
    +++ b/src/jexer/demos/DesktopDemoApplication.java
    @@ -40,6 +40,71 @@ import jexer.menu.*;
      */
     public class DesktopDemoApplication extends TApplication {
     
    +    // ------------------------------------------------------------------------
    +    // Constructors -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
    +    /**
    +     * Public constructor.
    +     *
    +     * @param backendType one of the TApplication.BackendType values
    +     * @throws Exception if TApplication can't instantiate the Backend.
    +     */
    +    public DesktopDemoApplication(final BackendType backendType) throws Exception {
    +        super(backendType);
    +        addAllWidgets();
    +        getBackend().setTitle("Jexer Demo Application");
    +    }
    +
    +    // ------------------------------------------------------------------------
    +    // TApplication -----------------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
    +    /**
    +     * Handle menu events.
    +     *
    +     * @param menu menu event
    +     * @return if true, the event was processed and should not be passed onto
    +     * a window
    +     */
    +    @Override
    +    public boolean onMenu(final TMenuEvent menu) {
    +
    +        if (menu.getId() == TMenu.MID_OPEN_FILE) {
    +            try {
    +                String filename = fileOpenBox(".");
    +                 if (filename != null) {
    +                     try {
    +                         File file = new File(filename);
    +                         StringBuilder fileContents = new StringBuilder();
    +                         Scanner scanner = new Scanner(file);
    +                         String EOL = System.getProperty("line.separator");
    +
    +                         try {
    +                             while (scanner.hasNextLine()) {
    +                                 fileContents.append(scanner.nextLine() + EOL);
    +                             }
    +                             new DemoTextWindow(this, filename,
    +                                 fileContents.toString());
    +                         } finally {
    +                             scanner.close();
    +                         }
    +                     } catch (IOException e) {
    +                         e.printStackTrace();
    +                     }
    +                 }
    +            } catch (IOException e) {
    +                e.printStackTrace();
    +            }
    +            return true;
    +        }
    +        return super.onMenu(menu);
    +    }
    +
    +    // ------------------------------------------------------------------------
    +    // DesktopDemoApplication -------------------------------------------------
    +    // ------------------------------------------------------------------------
    +
         /**
          * Add all the widgets of the demo.
          */
    @@ -189,56 +254,4 @@ public class DesktopDemoApplication extends TApplication {
     
         }
     
    -    /**
    -     * Handle menu events.
    -     *
    -     * @param menu menu event
    -     * @return if true, the event was processed and should not be passed onto
    -     * a window
    -     */
    -    @Override
    -    public boolean onMenu(final TMenuEvent menu) {
    -
    -        if (menu.getId() == TMenu.MID_OPEN_FILE) {
    -            try {
    -                String filename = fileOpenBox(".");
    -                 if (filename != null) {
    -                     try {
    -                         File file = new File(filename);
    -                         StringBuilder fileContents = new StringBuilder();
    -                         Scanner scanner = new Scanner(file);
    -                         String EOL = System.getProperty("line.separator");
    -
    -                         try {
    -                             while (scanner.hasNextLine()) {
    -                                 fileContents.append(scanner.nextLine() + EOL);
    -                             }
    -                             new DemoTextWindow(this, filename,
    -                                 fileContents.toString());
    -                         } finally {
    -                             scanner.close();
    -                         }
    -                     } catch (IOException e) {
    -                         e.printStackTrace();
    -                     }
    -                 }
    -            } catch (IOException e) {
    -                e.printStackTrace();
    -            }
    -            return true;
    -        }
    -        return super.onMenu(menu);
    -    }
    -
    -    /**
    -     * Public constructor.
    -     *
    -     * @param backendType one of the TApplication.BackendType values
    -     * @throws Exception if TApplication can't instantiate the Backend.
    -     */
    -    public DesktopDemoApplication(final BackendType backendType) throws Exception {
    -        super(backendType);
    -        addAllWidgets();
    -        getBackend().setTitle("Jexer Demo Application");
    -    }
     }
    diff --git a/src/jexer/menu/TMenu.java b/src/jexer/menu/TMenu.java
    index be4cf5d..505af3e 100644
    --- a/src/jexer/menu/TMenu.java
    +++ b/src/jexer/menu/TMenu.java
    @@ -128,8 +128,8 @@ public final class TMenu extends TWindow {
          * @param x column relative to parent
          * @param y row relative to parent
          * @param label mnemonic menu title.  Label must contain a keyboard
    -     * shortcut (mnemonic), denoted by prefixing a letter with "&",
    -     * e.g. "&File"
    +     * shortcut (mnemonic), denoted by prefixing a letter with "&",
    +     * e.g. "&File"
          */
         public TMenu(final TApplication parent, final int x, final int y,
             final String label) {
    @@ -620,7 +620,7 @@ public final class TMenu extends TWindow {
          * Convenience function to add a sub-menu.
          *
          * @param title menu title.  Title must contain a keyboard shortcut,
    -     * denoted by prefixing a letter with "&", e.g. "&File"
    +     * denoted by prefixing a letter with "&", e.g. "&File"
          * @return the new sub-menu
          */
         public TSubMenu addSubMenu(final String title) {
    diff --git a/src/jexer/menu/TSubMenu.java b/src/jexer/menu/TSubMenu.java
    index 88094da..488ccd4 100644
    --- a/src/jexer/menu/TSubMenu.java
    +++ b/src/jexer/menu/TSubMenu.java
    @@ -58,7 +58,7 @@ public final class TSubMenu extends TMenuItem {
          *
          * @param parent parent widget
          * @param title menu title.  Title must contain a keyboard shortcut,
    -     * denoted by prefixing a letter with "&", e.g. "&File"
    +     * denoted by prefixing a letter with "&", e.g. "&File"
          * @param x column relative to parent
          * @param y row relative to parent
          */
    @@ -246,7 +246,7 @@ public final class TSubMenu extends TMenuItem {
          * Convenience function to add a sub-menu.
          *
          * @param title menu title.  Title must contain a keyboard shortcut,
    -     * denoted by prefixing a letter with "&", e.g. "&File"
    +     * denoted by prefixing a letter with "&", e.g. "&File"
          * @return the new sub-menu
          */
         public TSubMenu addSubMenu(final String title) {
    diff --git a/src/jexer/package-info.java b/src/jexer/package-info.java
    index e43328f..46c48fa 100644
    --- a/src/jexer/package-info.java
    +++ b/src/jexer/package-info.java
    @@ -41,7 +41,6 @@
      * still being worked on.  Generally the goal will be to build applications
      * somewhat as follows:
      *
    - * 

    *

      * {@code
      * import jexer.*;
    -- 
    2.27.0