java windowclosing_最后一个方法public void windowClosing(WindowEvent e){}起什么作用?...

已结贴√

问题点数:10 回复次数:2

ca56232b3bbedf9a539d07f37fffb99a.gif

3144d8b7615c79d9f638db40d5689d26.gif

a218af6549b45ee526caf607ebff1358.gif

0f8df0e29816ae721419de940fb833d1.gif

最后一个方法public void windowClosing(WindowEvent e){}起什么作用?

import java.awt.*;

import java.awt.event.*;

import *;

public class WinAdapter extends WindowAdapter implements ActionListener{

Frame fr;

Panel p1,p2,p3;

Label lb1,lb2,lsp1,lsp2;

TextField tf1,tf2;

Button bClear,bCopy,bClose;

public void go(){

fr=new Frame("MyFrame");

fr.setSize(350, 250);

fr.setLayout(new GridLayout(6,1,0,8));

p1=new Panel();

p2=new Panel();

p3=new Panel();

lb1=new Label("Source");

lb2=new Label("Target");

lsp1=new Label();

lsp2=new Label();

tf1=new TextField(15);

tf2=new TextField(15);

bClear=new Button("Clear");

bCopy=new Button("Copy");

bClose=new Button("Close");

bClear.addActionListener(this);

bCopy.addActionListener(this);

bClose.addActionListener(this);

p1.add(lb1);

p1.add(tf1);

p2.add(lb2);

p2.add(tf2);

p3.setLayout(new FlowLayout(FlowLayout.CENTER,40,0));

p3.add(bClear);

p3.add(bCopy);

p3.add(bClose);

fr.add(lsp1);

fr.add(p1);

fr.add(p2);

fr.add(lsp2);

fr.add(p3);

fr.setVisible(true);

}

public void actionPerformed(ActionEvent e){

if(e.getSource()==bClear){

tf1.setText("");

tf2.setText("");

}

if(e.getSource()==bCopy){

tf2.setText(tf1.getText());

}

if(e.getSource()==bClose){

System.exit(0);

}

}

public static void main(String[] args){

WinAdapter wa=new WinAdapter();

wa.go();

BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Press enter key to exit");

try{

bf.readLine();

}catch(IOException e){

System.out.print("IOException");

}finally{

System.exit(0);

}

}

public void windowClosing(WindowEvent e){

System.exit(0);

}

}

搜索更多相关主题的帖子:

import public

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值