当程序在后台运行时,是否有任何方法可以从用户那里获取输入?
You can easily pop up a GUI asking for input. The following prompts the user for a string:
String myString = JOptionPane.showInputDialog("Input some string");
You will need to import javax.swing.JOptionPane
The javadoc is at 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.