本文介绍了单击按钮关闭JFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有JFrame的jButton1私有成员,我想在单击按钮时关闭框架。
I have the jButton1 private member of JFrame and i wanted to close the frame when the button is clicked.
jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } });我想做 super.close()但是找不到超级优惠。有没有办法引用JFrame
I wanted to do super.close() but could not find close for super. Is there some way to refer to the JFrame
推荐答案你需要引用你要关闭的特定帧但是假设你引用 dispose()应该关闭框架。
You will need a reference to the specific frame you want to close but assuming you have the reference dispose() should close the frame.
jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { frameToClose.dispose(); } });更多推荐
单击按钮关闭JFrame
发布评论