码迷,mamicode.com
首页 > 其他好文 > 详细

e565. 关闭的时候隐藏窗口

时间:2018-09-06 11:07:36      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:when   get   body   adapter   col   frame   button   ble   hid   

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. 关闭的时候隐藏窗口

标签:when   get   body   adapter   col   frame   button   ble   hid   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!