首页 > 其他 > 详细

e565. 关闭的时候隐藏窗口

时间:2018-09-06 10:13:41      阅读:137      评论:0      收藏:0      [点我收藏+]

By default, when the close button on a frame is clicked, nothing happens. This example shows how to make the action hide the frame. One reason for hiding rather than disposing a frame would be to reuse the frame later.

    // Create a frame
    Frame frame = new Frame();
    
    // Add a listener for the close event
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            Frame frame = (Frame)evt.getSource();
    
            // Hide the frame
            frame.setVisible(false);
    
            // If the frame is no longer needed, call dispose
            frame.dispose();
        }
    });

 

Related Examples

e565. 关闭的时候隐藏窗口

原文:https://www.cnblogs.com/borter/p/9596108.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!