kooyee ‘s blog

          開源軟件, 眾人努力的結晶, 全人類的共同財富
          posts - 103, comments - 55, trackbacks - 0, articles - 66
             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          按鍵退出applet or frame

          Posted on 2008-02-16 23:12 kooyee 閱讀(325) 評論(0)  編輯  收藏 所屬分類: Swing/Applet
          exit = new javax.swing.JButton();
           

           
          exit.addActionListener(
          new java.awt.event.ActionListener() {
                
          public void actionPerformed(java.awt.event.ActionEvent evt) {
                       exitActionPerformed(evt);
                  }

          }
          );
           

           
          private void exitActionPerformed(java.awt.event.ActionEvent evt) {
                  
          try {  
                           System.exit(
          0);
               }
           catch (Exception e){
                      input.setText(
          "Error: " + e.toString());
                  }

              }


          對于frame除了這個方法外 還可以用dispose()
          btnClose.addActionListener( 
                   
                                  
          new ActionListener() 
                                 
          {
                                         
          // pass query to tthe frame
                                       public void actionPerformed( ActionEvent event )
                                       
          {
                           
                                           dispose();
                           
                                       }
           // end actionPerformed
                                   }
            // end ActionListener inner class          
                                ); // end call to addActionListener 
          主站蜘蛛池模板: 井研县| 金乡县| 梁平县| 镶黄旗| 崇礼县| 铁岭市| 寿光市| 阳城县| 启东市| 和龙市| 松原市| 微山县| 兴安县| 顺义区| 盐城市| 西峡县| 紫金县| 富源县| 八宿县| 当雄县| 清涧县| 工布江达县| 封丘县| 莆田市| 金乡县| 明星| 海兴县| 通道| 大埔县| 安阳市| 高台县| 个旧市| 永春县| 宁夏| 屏边| 新密市| 涡阳县| 留坝县| 巨鹿县| 鸡东县| 金昌市|