public FrameEventDemo() {
getContentPane().setLayout(null);
JLabel lbable = new JLabel("New label");
lbable.setBounds(74, 51, 54, 15);
getContentPane().add(lbable);
setTitle("关闭提示");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lbNumber = new JLabel("New label");
lbNumber.setBounds(75, 51, 54, 15);
contentPane.add(lbNumber);
addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent e){
do_this_windowClosing(e);
}
});
}
protected void do_this_windowClosing(WindowEvent e){
this.lbNumber.Text = "aaa";
}
label的控件变量名改为lbNumber要怎么在protected void do_this_windowClosing(WindowEvent e)里面使用呀
------解决思路----------------------
把lbNumber这个变量做成全局变量,声明到构造方法外面,然后在protected void do_this_windowClosing(WindowEvent e)里面加上this.lbNumber.setText("aaaa");