lanterna swingterminal将不显示

djmepvbi  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(216)

我在windows上使用netbeanside和lanterna。我试图创建一个swingterminal,但它不会显示。

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

我也试过展示jframe,但是 nullSwingTerminal.getJFrame() .

t.getJFrame().setVisible(true);

我还试着从命令行运行这个程序,认为这可能是netbeans的问题,但它也不起作用(cygwin)。我怎样才能参加滑雪场的演出?

mznpcxlj

mznpcxlj1#

我应该先看看谷歌的讨论。从一堆片段拼凑而成:

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();
                }
            }
        );
    }

相关问题