Message Dialogs
Lines 22–23 use JOptionPane static method showMessageDialog to display a message dialog (the last screen of Fig. 12.2) containing the sum. The first argument helps the Java application determine where to position the dialog box. A dialog is typically displayed from a GUI application with its own window. The first argument refers to that window (known as the parent window) and causes the dialog to appear centered over the parent (as we’ll do in Section 12.9). If the first argument is null, the dialog box is displayed at the center of your screen. The second argument is the message to display—in this case, the result of concatenating the String "The sum is " and the value of sum. The third argument—"Sum of Two Integers"—is the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access