1

我在 Windows 上使用 NetBeans IDE 和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)。如何制作 SwingTerminal 节目?

4

1 回答 1

0

我应该先看看谷歌讨论。从一堆片段中破解:

    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();
                }
            }
        );
    }
于 2015-01-15T02:47:44.577 回答