Class App.Builder

  • Enclosing class:
    App

    public static final class App.Builder
    extends java.lang.Object
    Fluent builder for an App.
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • root

        public App.Builder root​(Section root)
        Sets the root section of the UI.
        Parameters:
        root - the root section
        Returns:
        this Builder for chaining
      • focusOrder

        public App.Builder focusOrder​(Section... targets)
        Sets the sections that participate in focus navigation, in order.
        Parameters:
        targets - the focusable sections in navigation order
        Returns:
        this Builder for chaining
      • navigation

        public App.Builder navigation​(Navigation navigation)
        Sets the navigation strategy that moves focus between targets.
        Parameters:
        navigation - the navigation strategy
        Returns:
        this Builder for chaining
      • initialFocus

        public App.Builder initialFocus​(Section target)
        Sets the section that holds focus when the app starts.
        Parameters:
        target - the initially focused section
        Returns:
        this Builder for chaining
      • onQuit

        public App.Builder onQuit​(java.util.function.Predicate<KeyEvent> predicate)
        Quits when a key matches the predicate.
        Parameters:
        predicate - tested against each key event
        Returns:
        this Builder for chaining
      • onQuitKey

        public App.Builder onQuitKey​(Key key)
        Quits on a specific logical key.
        Parameters:
        key - the logical key that triggers quit
        Returns:
        this Builder for chaining
      • onQuitKey

        public App.Builder onQuitKey​(char ch)
        Quits on a specific printable character.
        Parameters:
        ch - the character that triggers quit
        Returns:
        this Builder for chaining
      • onError

        public App.Builder onError​(java.util.function.Consumer<java.lang.Throwable> handler)
        Sets a handler for exceptions thrown by a task, key handler, or section render, invoked on the UI thread. Without one, the loop keeps running and the first error is printed after the terminal is restored.
        Parameters:
        handler - the error handler
        Returns:
        this Builder for chaining
      • build

        public App build()
        Builds the configured app.
        Returns:
        the new app
        Throws:
        java.lang.IllegalStateException - if no root section is set