• Java关闭窗口和刷新


    // 关闭窗口 写法1:
        public Structure() {
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    closeWindows();
                }
            });
        }
    
        private void closeWindows() {
            this.dispose();
        }
    
    // 关闭窗口 写法2:
        public Structure() {
            WindowListener wndCloser = new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            };
    
            addWindowListener(wndCloser);
        }
    
    // 设置控件边界及其标题:
        jPanel.setBorder(new TitledBorder("jPanel"));
    
    // 设置控件颜色:
        jButton1.setBackground(Color.YELLOW);
    
    ################################################################################
    
    <刷新>:
        在swing编程时, 建议用validate()这个方法,能及时查验组件;
        在awt  编程时, 建议用repaint()这个方法, 是尽可能去重绘组件。
    
    ################################################################################
  • 相关阅读:
    Vue状态管理
    Vue延迟点击
    Vue路由
    简单的队列应用
    Uncaught SyntaxError: Unexpected token )
    视频转码
    判断是否为视频文件
    Press ^C at any time to quit.
    Node.js学习
    YUM安装LAMP与LNMP
  • 原文地址:https://www.cnblogs.com/xuejianhui/p/2780258.html
Copyright © 2020-2023  润新知