It is often useful to display messages to inform the user that something has occurred, to have the user answer a Yes/No question, or offer debugging information to help determine why a script isn't working as expected. Text information can be displayed in the console window as described in Outputting Text.
Displaying Message Dialogs
The java language JOptionPane class has several functions used to display messages in message box dialogs. The JOptionPane dialogs support different types of messages: Error, Warning, Informational, Question, or Plain. Oracle has detailed documentation here: https://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html
Note: Do not use the dialogs in a script that is to run unattended since these functions cause scripts to pause for user interaction.
Example 13: Display Error Dialog with MessageBox class
from javax.swing import JOptionPane
# shows dialog with error symbol
JOptionPane.showMessageDialog(None, "alert", "Alert Title", JOptionPane.ERROR_MESSAGE);
PY
Example 14: Display OK/Cancel Dialog with MessageDialog class
from javax.swing import JOptionPane
# presents dialog with Yes or No question
opt = JOptionPane.showConfirmDialog(None,"choose one", "choose one Title", JOptionPane.YES_NO_OPTION)
if opt == None:
print("closed without answer")
elif opt == JOptionPane.NO_OPTION :
print(" User selected No")
elif opt == JOptionPane.YES_OPTION :
print(" User selected Yes")
PY