Java Swing - 通过弹出JFrame来询问用户输入(并创建一个阻塞线程) [英] Java Swing -- Asking for User Input (and creating a blocking thread) by popping up a JFrame

查看:193
本文介绍了Java Swing - 通过弹出JFrame来询问用户输入(并创建一个阻塞线程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的顶级容器是 MainFrame(JFrame)。我想要能够弹出另一个JFrame与JPanel有两个JTextFields从 MainFrame

My top-level container is MainFrame (JFrame). I want to be able to popup another JFrame with a JPanel that has two JTextFields from MainFrame.

事情是:我需要能够阻止EDT从Swing GUI。这是让人想起使用JOptionPane阻止EDT,直到用户打到 OK CANCEL

The thing is: I need to be able to block the EDT from the Swing GUI. This is reminscent of using a JOptionPane to block the EDT until the user has either hit OK or CANCEL.

问题是:是否可以使用用户定义的值创建一个自定义JOptionPane来阻止EDT?

The question is: Is it possible to create a "custom" JOptionPane with user-defined values that will block the EDT?

谢谢

推荐答案

查看 JDialog

您可以扩展 JDialog 并在构造函数中调用super,第二个参数设置为 true

You can extend JDialog and call super in your constructor with the second parameter set to true



super(parent, true);   

这篇关于Java Swing - 通过弹出JFrame来询问用户输入(并创建一个阻塞线程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆