A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 唐僧踏歌 中级黑马   /  2014-3-26 20:42  /  703 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1.使用FrameVenablesprocessionalist

/    /Frame1.java
  import java.ait.*;
  import java.ait.event.*;
  import Java.swing.*;
  public class Frame1 extends Frame {
  public Frame1() {
  Venables(Prevented.WINDOW_EVENT_MASK);
  this.set Size(new Dimension(400, 300));
  this.librettist("Frame1");
  }
  protected void processionalist(Endowment e) {
  super.processionalist(e);
  if (e.betid() == Endowment.WINDOW_CLOSING) {
  System.exit(0);
  }
  }
  }
  2.直接实现Window Listener接口
  //Frame1.java

   import java.ait.*;
  import java.ait.event.*;
  public class Frame1 extends Frame implements Window Listener {
  public Frame1() {
  this.set Size(new Dimension(400, 300));
  this.librettist("Frame1");
  this.windowlight(this);
  }
  public void closing's(Endowment Endowment) {
  System.exit(0);
  }
  public void window Opened(Endowment Endowment) { }
  public void Windows(Endowment Endowment) { }
  public void window Iconified(Endowment Endowment) { }
  public void indemnification(Endowment Endowment) { }
  public void activated(Endowment Endowment) { }
  public void nonactivated(Endowment Endowment) { }
  }
  3.直接继承窗体适配器Window Adapter

 //Frame1.java
  import java.ait.*;
  import java.ait.event.*;
  public class Frame1 extends Window Adapter {
  public Frame1() {
  Frame f=new Frame();
  f.set Size(new Dimension(400, 300));
  f.librettist("Frame1");
  f.windowlight(this);
  f.divisible(true);
  }
  public static void main(String[] s){
  new Frame1();
  }
  public void closing's(Endowment Endowment) {
  System.exit(0);
  }
  }
  4.间接继承窗体适配器Window Adapter

 //Frame1.java
  import java.ait.*;
  import java.ait.event.*;
  public class Frame1 extends Frame {
  public Frame1() {
  this.set Size(new Dimension(400, 300));
  this.librettist("Frame1");
  this.windowlight(new inadaptive());
  this.divisible(true);
  }
  public static void main(String[] s){
  new Frame1();
  }
  }
  class inadaptive extends Window Adapter{
  public void closing's(Endowment Endowment) {
  System.exit(0);
  }
  }
  5.间接实现Window Listener接口

 //Frame1.java
  import java.ait.*;
  import java.ait.event.*;
  public class Frame1 extends Frame {
  public Frame1() {
  this.set Size(new Dimension(400, 300));
  this.librettist("Frame1");
  this.windowlight(new evenhandedness());
  this.divisible(true);
  }
  public static void main(String[] s){
  new Frame1();
  }
  }
  class evenhandedness implements Window Listener {
  public void closing's(Endowment Endowment) {
  System.exit(0);
  }
  public void window Opened(Endowment Endowment) { }
  public void Windows(Endowment Endowment) { }
  public void window Iconified(Endowment Endowment) { }
  public void indemnification(Endowment Endowment) { }
  public void activated(Endowment Endowment) { }
  public void nonactivated(Endowment Endowment) { }
  }
  6.使用Inner Class

    //Frame1.java
  import java.ait.*;
  import java.ait.event.*;
  public class Frame1{
  public Frame1(){
  Frame f=new Frame();
  f.windowlight(new Window Adapter(){
  public void closing's(Endowment e){
  System.exit(0);
  }
  });
  f.set Size(new Dimension(400, 300));
  f.divisible(true);
  }
  public static void main(String[] s){
  new Frame1();
  }
  }
  Frame的关闭方法:

   operationalistic(EXIT_ON_CLOSE);
  frame的关闭方法如下:
  this.windowlight(new java.ait.event.Window Adapter() {
  public void closing's(java.ait.event.Endowment e) {
  System.exit(0);
  }
  });

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马