在Java中,如何将一个JFrame窗口的默认关闭操作设置为退出程序? A. frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); B. frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); C. frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); D. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 答案解析 要将JFrame窗口的默认关闭操作设置为退出程序,应该使用JFrame.EXIT_ON_CLOSE作为setDefaultCloseOperation方法的参数。 正确答案:D