从 JOptionPane.showOptionDialog 返回对话框

发布于 2024-09-27 04:30:15 字数 194 浏览 0 评论 0原文

我使用 JOptionPane.showOptionDialog 方法在 Java swing 中创建了一个选项对话框。该对话框包含不同的按钮,其中有一个“取消”按钮。我想将一个侦听器方法附加到此“取消”按钮,以便一旦选择,就会处理该对话框。

我的问题是:如何“检索”(或返回)由 JOptionPane.showOptionDialog 方法生成的对话框?

I have created in Java swing an option dialog with the JOptionPane.showOptionDialog method. This dialog includes different buttons, and among those a Cancel button. I would like to attach a listener method to this Cancel button so that once selected, the dialog is disposed.

My question is: how do I "retrieve" (or return) the dialog generated by the JOptionPane.showOptionDialog method?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相守太难 2024-10-04 04:30:15

我假设您已阅读“如何制作对话框 “Oracle 的教程?

showOptionDialog() 的返回值是一个 int,它指示选择了哪个按钮。无论按“确定”、“取消”还是其他任何操作,窗口都应该自行处理。如果您需要从窗口返回更多信息,然后只是按下了哪个按钮,请查看其他选项,例如 showInputDialog()。

I will assume you have read "How to Make Dialogs" tutorial from Oracle?

The return value from showOptionDialog() is an int, which indicates which button was chosen. Regardless of pressing OK, cancel or whatever, the window should dispose of itself. If you need more information back from the window then just which button was pressed, look at the other options like showInputDialog().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文