单击按钮关闭JFrame

编程入门 行业动态 更新时间:2024-10-28 12:21:16
本文介绍了单击按钮关闭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

本文发布于:2023-11-08 11:54:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   按钮   JFrame

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!