1

I'm on Windows using NetBeans IDE and lanterna. I try to create a SwingTerminal, but it won't show.

    public static void main(String[] args) throws Exception {
        SwingTerminal t = TerminalFacade.createSwingTerminal();
        while (true) {
            Thread.sleep(100);
        }
    }

I also tried displaying the JFrame, but I get null from SwingTerminal.getJFrame().

    t.getJFrame().setVisible(true);

I also tried running the program from the command-line, thinking it might be an issue with NetBeans, but it didn't work either (cygwin). How can I make the SwingTerminal show?

Niklas R
  • 16,299
  • 28
  • 108
  • 203

1 Answers1

0

I should've look at the Google Discussions first. Hacked together from a bunch of snippets:

    public static void main(String[] args) {
        // Create a Terminal and Screen.
        SwingTerminal terminal = new SwingTerminal();
        Screen screen = new Screen(terminal);
        screen.startScreen();

        // Add listener(s) for the Window. The JFrame won't shut
        // down itself when Alt+F4 or the like is pressed or the
        // Window is closed by pressing the X button.
        terminal.getJFrame().addWindowListener(
            new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    screen.stopScreen();
                }
            }
        );
    }
Niklas R
  • 16,299
  • 28
  • 108
  • 203