zoukankan      html  css  js  c++  java
  • 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()这个方法, 是尽可能去重绘组件。
    
    ################################################################################
  • 相关阅读:
    进程二
    高德地图api的使用
    《架构即未来》读后感3
    三周总结
    性能战术:
    二周总结
    《 架构即未来》读后感2
    一周总结
    《架构即未来》读后感
    学生信息系统dao层
  • 原文地址:https://www.cnblogs.com/xuejianhui/p/2780258.html
Copyright © 2011-2022 走看看