[英]How to get input from the user with a java program running in the background? (SetWindowsHookEx)
当程序在后台运行时,是否有任何方法可以从用户那里获取输入?
You can easily pop up a GUI asking for input. 您可以轻松弹出GUI进行输入。 The following prompts the user for a string:
以下提示用户输入字符串:
String myString = JOptionPane.showInputDialog("Input some string");
You will need to import javax.swing.JOptionPane
您将需要导入
javax.swing.JOptionPane
The javadoc is at http://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html . Javadoc位于http://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html 。 Note that
JOptionPane.showInputDialog()
will return null
if the user cancels out of the dialog. 请注意,如果用户从对话框中取消,则
JOptionPane.showInputDialog()
将返回null
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.