Using the class JOptionPane, it is also possible to send output to a dialog window. Specifically, the method showMessageDialog() can be used. The following program illustrates its use:
import javax.swing.JOptionPane; public class OutputWindow { public static void main(String[] args) { String name = JOptionPane.showInputDialog("What is your name?"); name = name.toUpperCase(); String stringToShow = "Hy " + name + ", how are you?"; JOptionPane.showMessageDialog(null, stringToShow); System.exit(0); } }